本文整理汇总了Java中org.apache.ivy.Ivy.getSettings方法的典型用法代码示例。如果您正苦于以下问题:Java Ivy.getSettings方法的具体用法?Java Ivy.getSettings怎么用?Java Ivy.getSettings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ivy.Ivy
的用法示例。
在下文中一共展示了Ivy.getSettings方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doExecute
import org.apache.ivy.Ivy; //导入方法依赖的package包/类
public void doExecute() throws BuildException {
if (organisation == null) {
throw new BuildException("no organisation provided for ivy findrevision task");
}
if (module == null) {
throw new BuildException("no module name provided for ivy findrevision task");
}
if (revision == null) {
throw new BuildException("no revision provided for ivy findrevision task");
}
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
if (branch == null) {
branch = settings.getDefaultBranch(new ModuleId(organisation, module));
}
ResolvedModuleRevision rmr = ivy.findModule(ModuleRevisionId.newInstance(organisation,
module, branch, revision));
if (rmr != null) {
getProject().setProperty(property, rmr.getId().getRevision());
}
}
示例2: testFile
import org.apache.ivy.Ivy; //导入方法依赖的package包/类
@Test
public void testFile() throws Exception {
configure.setFile(new File("test/repositories/ivysettings.xml"));
configure.execute();
Ivy ivy = getIvyInstance();
assertNotNull(ivy);
IvySettings settings = ivy.getSettings();
assertNotNull(settings);
assertEquals(new File("build/cache").getAbsoluteFile(), settings.getDefaultCache());
assertEquals(new File("test/repositories/ivysettings.xml").getAbsolutePath(), settings
.getVariables().getVariable("ivy.settings.file"));
assertEquals(
new File("test/repositories/ivysettings.xml").toURI().toURL().toExternalForm(),
settings.getVariables().getVariable("ivy.settings.url"));
assertEquals(new File("test/repositories").getAbsolutePath(), settings.getVariables()
.getVariable("ivy.settings.dir"));
assertEquals("myvalue", settings.getVariables().getVariable("myproperty"));
}
示例3: setUp
import org.apache.ivy.Ivy; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
File f = File.createTempFile("ivycache", ".dir");
ivy = new Ivy();
ivy.configureDefault();
ivy.getLoggerEngine().setDefaultLogger(new DefaultMessageLogger(Message.MSG_DEBUG));
IvyContext.pushNewContext().setIvy(ivy);
IvySettings settings = ivy.getSettings();
f.delete(); // we want to use the file as a directory, so we delete the file itself
cacheManager = new DefaultRepositoryCacheManager();
cacheManager.setSettings(settings);
cacheManager.setBasedir(f);
artifact = createArtifact("org", "module", "rev", "name", "type", "ext");
Artifact originArtifact = createArtifact("org", "module", "rev", "name", "pom.original",
"pom");
origin = new ArtifactOrigin(originArtifact, true, "file:/some/where.pom");
cacheManager.saveArtifactOrigin(originArtifact, origin);
cacheManager.saveArtifactOrigin(artifact, origin);
}
示例4: testChangeDefaultResolver
import org.apache.ivy.Ivy; //导入方法依赖的package包/类
@Test
public void testChangeDefaultResolver() throws ParseException, IOException {
Ivy ivy = new Ivy();
ivy.configureDefault();
IvySettings settings = ivy.getSettings();
DependencyResolver defaultResolver = settings.getDefaultResolver();
assertNotNull(defaultResolver);
assertEquals("default", defaultResolver.getName());
assertSame("default resolver cached", defaultResolver, settings.getDefaultResolver());
settings.setDefaultResolver("public");
DependencyResolver newDefault = settings.getDefaultResolver();
assertNotNull(newDefault);
assertNotSame("default resolver has changed", defaultResolver, newDefault);
assertEquals("resolver changed successfully", "public", newDefault.getName());
}
示例5: ivyContextualize
import org.apache.ivy.Ivy; //导入方法依赖的package包/类
private void ivyContextualize(IvyAwareModuleVersionRepository ivyAwareRepository, RepositoryChain userResolverChain, String configurationName) {
Ivy ivy = IvyContext.getContext().getIvy();
IvySettings ivySettings = ivy.getSettings();
LoopbackDependencyResolver loopbackDependencyResolver = new LoopbackDependencyResolver("main", userResolverChain, cacheLockingManager);
ivySettings.addResolver(loopbackDependencyResolver);
ivySettings.setDefaultResolver(loopbackDependencyResolver.getName());
ResolveData resolveData = createResolveData(ivy, configurationName);
ivyAwareRepository.setSettings(ivySettings);
ivyAwareRepository.setResolveData(resolveData);
}
示例6: doExecute
import org.apache.ivy.Ivy; //导入方法依赖的package包/类
public void doExecute() throws BuildException {
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
if (getName() != null) {
settings.setVariable(getVarName(getName()), getValue());
} else {
Properties props = new Properties();
InputStream is = null;
try {
if (getFile() != null) {
is = new FileInputStream(getFile());
} else if (getUrl() != null) {
is = new URL(getUrl()).openStream();
} else {
throw new BuildException("specify either name or file or url to ivy var task");
}
props.load(is);
} catch (Exception ex) {
throw new BuildException("impossible to load variables from file: " + ex, ex);
} finally {
if (is != null) {
try {
is.close();
} catch (Exception e) {
// ignore
}
}
}
for (Map.Entry<Object, Object> entry : props.entrySet()) {
settings.setVariable(getVarName((String) entry.getKey()), (String) entry.getValue());
}
}
}
示例7: testDefaultSettings
import org.apache.ivy.Ivy; //导入方法依赖的package包/类
@Test
public void testDefaultSettings() throws MalformedURLException {
Project p = TestHelper.newProject();
p.setBasedir("test/repositories");
p.setProperty("myproperty", "myvalue");
IvyTask task = new IvyTask() {
public void doExecute() throws BuildException {
}
};
task.setProject(p);
Ivy ivy = task.getIvyInstance();
assertNotNull(ivy);
IvySettings settings = ivy.getSettings();
assertNotNull(settings);
assertEquals(new File("test/repositories/build/cache").getAbsoluteFile(),
settings.getDefaultCache());
// The next test doesn't always works on windows (mix C: and c: drive)
assertEquals(new File("test/repositories/ivysettings.xml").getAbsolutePath().toUpperCase(),
new File(settings.getVariables().getVariable("ivy.settings.file")).getAbsolutePath()
.toUpperCase());
assertEquals(new File("test/repositories/ivysettings.xml").toURI().toURL().toExternalForm()
.toUpperCase(), settings.getVariables().getVariable("ivy.settings.url")
.toUpperCase());
assertEquals(new File("test/repositories").getAbsolutePath().toUpperCase(), settings
.getVariables().getVariable("ivy.settings.dir").toUpperCase());
assertEquals("myvalue", settings.getVariables().getVariable("myproperty"));
}
示例8: testReferencedSettings
import org.apache.ivy.Ivy; //导入方法依赖的package包/类
@Test
public void testReferencedSettings() throws MalformedURLException {
Project p = TestHelper.newProject();
p.setProperty("myproperty", "myvalue");
IvyAntSettings antSettings = new IvyAntSettings();
antSettings.setProject(p);
// antSettings.setId("mySettings");
antSettings.setFile(new File("test/repositories/ivysettings.xml"));
p.addReference("mySettings", antSettings);
IvyTask task = new IvyTask() {
public void doExecute() throws BuildException {
}
};
task.setProject(p);
task.setSettingsRef(new Reference(task.getProject(), "mySettings"));
Ivy ivy = task.getIvyInstance();
assertNotNull(ivy);
IvySettings settings = ivy.getSettings();
assertNotNull(settings);
assertEquals(new File("build/cache").getAbsoluteFile(), settings.getDefaultCache());
assertEquals(new File("test/repositories/ivysettings.xml").getAbsolutePath(), settings
.getVariables().getVariable("ivy.settings.file"));
assertEquals(
new File("test/repositories/ivysettings.xml").toURI().toURL().toExternalForm(),
settings.getVariables().getVariable("ivy.settings.url"));
assertEquals(new File("test/repositories").getAbsolutePath(), settings.getVariables()
.getVariable("ivy.settings.dir"));
assertEquals("myvalue", settings.getVariables().getVariable("myproperty"));
}
示例9: testOptionalFileInclude
import org.apache.ivy.Ivy; //导入方法依赖的package包/类
/**
* Tests that if the Ivy settings file <code>include</code>s another file as
* <code>optional</code>, then the absence of that file doesn't lead to failures
*
* @throws Exception if something goes wrong
*/
@Test
public void testOptionalFileInclude() throws Exception {
final File ivySettingsXml = new File("test/repositories/ivysettings-optional-file-include.xml");
final Ivy ivy = new Ivy();
ivy.configure(ivySettingsXml);
final IvySettings ivySettings = ivy.getSettings();
// just test that it indeed parsed fine
assertTrue("Unexpected number of resolvers in Ivy settings", ivySettings.getResolvers().isEmpty());
final List<Status> statuses = ivySettings.getStatusManager().getStatuses();
assertEquals("Unexpected number of custom status in parsed Ivy settings", 1, statuses.size());
assertEquals("Custom status not found in the parsed Ivy settings", "ivy-1555", statuses.get(0).getName());
}
示例10: testListModulesWithExtraAttributes
import org.apache.ivy.Ivy; //导入方法依赖的package包/类
@Test
public void testListModulesWithExtraAttributes() throws ParseException, IOException {
Ivy ivy = Ivy.newInstance();
ivy.configure(new File("test/repositories/IVY-1128/ivysettings.xml"));
IvySettings settings = ivy.getSettings();
Map<String, String> extendedAttributes = new HashMap<>();
extendedAttributes.put("e:att1", "extraatt");
extendedAttributes.put("e:att2", "extraatt2");
ModuleRevisionId criteria = ModuleRevisionId.newInstance("test", "a", "*",
extendedAttributes);
ModuleRevisionId[] mrids = ivy.listModules(criteria,
settings.getMatcher(PatternMatcher.REGEXP));
assertEquals(2, mrids.length);
ModuleRevisionId mrid = mrids[0];
assertEquals("extraatt", mrid.getExtraAttribute("att1"));
Map<String, String> extraAttributes = mrid.getExtraAttributes();
assertEquals(2, extraAttributes.size());
assertTrue(extraAttributes.toString(), extraAttributes.keySet().contains("att1"));
assertTrue(extraAttributes.toString(), extraAttributes.keySet().contains("att2"));
Map<String, String> qualifiedExtraAttributes = mrid.getQualifiedExtraAttributes();
assertEquals(2, qualifiedExtraAttributes.size());
assertTrue(qualifiedExtraAttributes.toString(),
qualifiedExtraAttributes.keySet().contains("e:att1"));
assertTrue(qualifiedExtraAttributes.toString(),
qualifiedExtraAttributes.keySet().contains("e:att2"));
}
示例11: testDefault
import org.apache.ivy.Ivy; //导入方法依赖的package包/类
@Test
public void testDefault() throws ParseException, IOException {
Ivy ivy = new Ivy();
ivy.configureDefault();
IvySettings settings = ivy.getSettings();
assertNotNull(settings.getDefaultResolver());
DependencyResolver publicResolver = settings.getResolver("public");
assertNotNull(publicResolver);
assertTrue(publicResolver instanceof IBiblioResolver);
IBiblioResolver ibiblio = (IBiblioResolver) publicResolver;
assertTrue(ibiblio.isM2compatible());
}
示例12: testDefault14
import org.apache.ivy.Ivy; //导入方法依赖的package包/类
@Test
public void testDefault14() throws ParseException, IOException {
Ivy ivy = new Ivy();
ivy.configureDefault14();
IvySettings settings = ivy.getSettings();
assertNotNull(settings.getDefaultResolver());
DependencyResolver publicResolver = settings.getResolver("public");
assertTrue(publicResolver instanceof IvyRepResolver);
}
示例13: doExecute
import org.apache.ivy.Ivy; //导入方法依赖的package包/类
public void doExecute() throws BuildException {
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
if (xsl && xslFile == null) {
throw new BuildException("xsl file is mandatory when using xsl generation");
}
if (module == null && PatternMatcher.EXACT.equals(matcher)) {
throw new BuildException("no module name provided for ivy repository graph task: "
+ "It can either be set explicitly via the attribute 'module' or "
+ "via 'ivy.module' property or a prior call to <resolve/>");
} else if (module == null && !PatternMatcher.EXACT.equals(matcher)) {
module = PatternMatcher.ANY_EXPRESSION;
}
ModuleRevisionId moduleRevisionId = ModuleRevisionId.newInstance(organisation, module, revision);
try {
ModuleRevisionId criteria = (revision == null) || settings.getVersionMatcher().isDynamic(moduleRevisionId)
? new ModuleRevisionId(new ModuleId(organisation, module), branch, "*")
: new ModuleRevisionId(new ModuleId(organisation, module), branch, revision);
ModuleRevisionId[] mrids = ivy.listModules(criteria, settings.getMatcher(matcher));
// replace all found revisions with the original requested revision
Set<ModuleRevisionId> modules = new HashSet<>();
for (ModuleRevisionId mrid : mrids) {
modules.add(ModuleRevisionId.newInstance(mrid, revision));
}
mrids = modules.toArray(new ModuleRevisionId[modules.size()]);
ModuleDescriptor md = DefaultModuleDescriptor.newCallerInstance(mrids, true, false);
String resolveId = ResolveOptions.getDefaultResolveId(md);
ResolveReport report = ivy.resolve(md, new ResolveOptions().setResolveId(resolveId)
.setValidate(doValidate(settings)));
ResolutionCacheManager cacheMgr = getIvyInstance().getResolutionCacheManager();
new XmlReportOutputter().output(report, cacheMgr, new ResolveOptions());
if (graph) {
gengraph(cacheMgr, md.getModuleRevisionId().getOrganisation(),
md.getModuleRevisionId().getName());
}
if (dot) {
gendot(cacheMgr, md.getModuleRevisionId().getOrganisation(),
md.getModuleRevisionId().getName());
}
if (xml) {
FileUtil.copy(cacheMgr.getConfigurationResolveReportInCache(resolveId, "default"),
new File(getTodir(), outputname + ".xml"), null);
}
if (xsl) {
genreport(cacheMgr, md.getModuleRevisionId().getOrganisation(),
md.getModuleRevisionId().getName());
}
} catch (Exception e) {
throw new BuildException("impossible to generate graph for " + moduleRevisionId + ": " + e, e);
}
}
示例14: doExecute
import org.apache.ivy.Ivy; //导入方法依赖的package包/类
public void doExecute() throws BuildException {
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
conf = getProperty(conf, settings, "ivy.resolved.configurations", resolveId);
if ("*".equals(conf)) {
conf = getProperty(settings, "ivy.resolved.configurations", resolveId);
}
if (conf == null) {
throw new BuildException("no conf provided for ivy report task: "
+ "It can either be set explicitly via the attribute 'conf' or "
+ "via 'ivy.resolved.configurations' property or a prior call to <resolve/>");
}
if (todir == null) {
String t = getProperty(settings, "ivy.report.todir");
if (t != null) {
todir = getProject().resolveFile(t);
}
}
if (todir != null && todir.exists()) {
todir.mkdirs();
}
outputpattern = getProperty(outputpattern, settings, "ivy.report.output.pattern");
if (outputpattern == null) {
outputpattern = "[organisation]-[module]-[conf].[ext]";
}
if (todir != null && todir.exists() && !todir.isDirectory()) {
throw new BuildException("destination directory should be a directory !");
}
if (resolveId == null) {
organisation = getProperty(organisation, settings, "ivy.organisation", resolveId);
module = getProperty(module, settings, "ivy.module", resolveId);
if (organisation == null) {
throw new BuildException("no organisation provided for ivy report task: "
+ "It can either be set explicitly via the attribute 'organisation' or "
+ "via 'ivy.organisation' property or a prior call to <resolve/>");
}
if (module == null) {
throw new BuildException("no module name provided for ivy report task: "
+ "It can either be set explicitly via the attribute 'module' or "
+ "via 'ivy.module' property or a prior call to <resolve/>");
}
resolveId = ResolveOptions.getDefaultResolveId(new ModuleId(organisation, module));
}
try {
String[] confs = splitToArray(conf);
if (xsl) {
genreport(confs);
}
if (xml) {
genxml(confs);
}
if (graph) {
genStyled(confs, getStylePath("ivy-report-graph.xsl"), "graphml");
}
if (dot) {
genStyled(confs, getStylePath("ivy-report-dot.xsl"), "dot");
}
} catch (IOException e) {
throw new BuildException("impossible to generate report: " + e, e);
}
}
示例15: doExecute
import org.apache.ivy.Ivy; //导入方法依赖的package包/类
public void doExecute() throws BuildException {
Ivy ivy = getIvyInstance();
IvySettings settings = ivy.getSettings();
if (organisation == null) {
throw new BuildException("no organisation provided for ivy publish task: "
+ "It can either be set explicitly via the attribute 'organisation' "
+ "or via 'ivy.organisation' property or a prior call to <resolve/>");
}
if (module == null) {
if (PatternMatcher.EXACT.equals(matcher)) {
throw new BuildException("no module name provided for ivy publish task: "
+ "It can either be set explicitly via the attribute 'module' "
+ "or via 'ivy.module' property or a prior call to <resolve/>");
}
module = PatternMatcher.ANY_EXPRESSION;
}
if (revision == null) {
if (PatternMatcher.EXACT.equals(matcher)) {
throw new BuildException("no module revision provided for ivy publish task: "
+ "It can either be set explicitly via the attribute 'revision' "
+ "or via 'ivy.revision' property or a prior call to <resolve/>");
}
revision = PatternMatcher.ANY_EXPRESSION;
}
if (branch == null) {
if (PatternMatcher.EXACT.equals(matcher)) {
branch = settings.getDefaultBranch(ModuleId.newInstance(organisation, module));
} else {
branch = PatternMatcher.ANY_EXPRESSION;
}
}
if (from == null) {
throw new BuildException(
"no from resolver name: please provide it through parameter 'from'");
}
if (to == null) {
throw new BuildException(
"no to resolver name: please provide it through parameter 'to'");
}
ModuleRevisionId mrid = ModuleRevisionId
.newInstance(organisation, module, branch, revision);
ResolveReport report;
try {
report = ivy.install(
mrid,
from,
to,
new InstallOptions().setTransitive(transitive).setValidate(doValidate(settings))
.setOverwrite(overwrite).setConfs(conf.split(","))
.setArtifactFilter(FilterHelper.getArtifactTypeFilter(type))
.setMatcherName(matcher)
.setInstallOriginalMetadata(installOriginalMetadata));
} catch (Exception e) {
throw new BuildException("impossible to install " + mrid + ": " + e, e);
}
if (report.hasError() && isHaltonfailure()) {
throw new BuildException(
"Problem happened while installing modules - see output for details");
}
}