use of org.apache.ivy.plugins.resolver.DependencyResolver in project ant-ivy by apache.
the class IvyNode method loadData.
/**
* After the call node may be discarded. To avoid using discarded node, make sure to get the
* real node after the call
* <code>IvyNode node = ... node.loadData(); node = node.getRealNode(); ...</code>
*
* @param rootModuleConf String
* @param parent IvyNode
* @param parentConf String
* @param conf String
* @param shouldBePublic boolean
* @param usage IvyNodeUsage
* @return boolean
*/
public boolean loadData(String rootModuleConf, IvyNode parent, String parentConf, String conf, boolean shouldBePublic, IvyNodeUsage usage) {
Message.debug("loadData of " + this.toString() + " of rootConf=" + rootModuleConf);
if (!isRoot() && (data.getReport() != null)) {
data.getReport().addDependency(this);
}
boolean loaded = false;
if (hasProblem()) {
Message.debug("Node has problem. Skip loading");
} else if (isEvicted(rootModuleConf)) {
Message.debug(rootModuleConf + " is evicted. Skip loading");
} else if (!hasConfigurationsToLoad() && isRootModuleConfLoaded(rootModuleConf)) {
Message.debug(rootModuleConf + " is loaded and no conf to load. Skip loading");
} else {
markRootModuleConfLoaded(rootModuleConf);
if (md == null) {
DependencyResolver resolver = data.getSettings().getResolver(getId());
if (resolver == null) {
Message.error("no resolver found for " + getModuleId() + ": check your configuration");
problem = new RuntimeException("no resolver found for " + getModuleId() + ": check your configuration");
return false;
}
try {
Message.debug("\tusing " + resolver + " to resolve " + getId());
DependencyDescriptor dependencyDescriptor = getDependencyDescriptor(parent);
long start = System.currentTimeMillis();
ModuleRevisionId requestedRevisionId = dependencyDescriptor.getDependencyRevisionId();
data.getEventManager().fireIvyEvent(new StartResolveDependencyEvent(resolver, dependencyDescriptor, requestedRevisionId));
module = resolver.getDependency(dependencyDescriptor, data);
data.getEventManager().fireIvyEvent(new EndResolveDependencyEvent(resolver, dependencyDescriptor, requestedRevisionId, module, System.currentTimeMillis() - start));
if (module != null) {
module.getResolver().getRepositoryCacheManager().saveResolvers(module.getDescriptor(), module.getResolver().getName(), module.getArtifactResolver().getName());
if (settings.logModuleWhenFound() && LogOptions.LOG_DEFAULT.equals(getData().getOptions().getLog())) {
Message.info("\tfound " + module.getId() + " in " + module.getResolver().getName());
} else {
Message.verbose("\tfound " + module.getId() + " in " + module.getResolver().getName());
}
// IVY-56: check if revision has actually been resolved
if (settings.getVersionMatcher().isDynamic(getId()) && settings.getVersionMatcher().isDynamic(module.getId())) {
Message.error("impossible to resolve dynamic revision for " + getId() + ": check your configuration and make sure revision is part of your pattern");
problem = new RuntimeException("impossible to resolve dynamic revision");
return false;
}
if (!getId().equals(module.getId())) {
IvyNode resolved = data.getNode(module.getId());
if (resolved != null) {
// found revision has already been resolved
// => update it and discard this node
// needed for handleConfiguration
md = module.getDescriptor();
if (!handleConfiguration(loaded, rootModuleConf, parent, parentConf, conf, shouldBePublic, usage)) {
return false;
}
moveToRealNode(rootModuleConf, parent, parentConf, conf, shouldBePublic, resolved);
return true;
}
String log = "\t[" + module.getId().getRevision() + "] " + getId();
if (!settings.getVersionMatcher().isDynamic(getId())) {
log += " (forced)";
}
if (settings.logResolvedRevision() && LogOptions.LOG_DEFAULT.equals(getData().getOptions().getLog())) {
Message.info(log);
} else {
Message.verbose(log);
}
}
downloaded = module.getReport().isDownloaded();
searched = module.getReport().isSearched();
loaded = true;
md = module.getDescriptor();
confsToFetch.remove("*");
updateConfsToFetch(Arrays.asList(resolveSpecialConfigurations(getRequiredConfigurations(parent, parentConf))));
} else {
Message.warn("\tmodule not found: " + getId());
resolver.reportFailure();
problem = new RuntimeException("not found");
return false;
}
} catch (ResolveProcessException e) {
throw e;
} catch (Exception e) {
problem = e;
Message.debug("Unexpected error: " + problem.getMessage(), problem);
return false;
}
} else {
loaded = true;
}
}
handleConfiguration(loaded, rootModuleConf, parent, parentConf, conf, shouldBePublic, usage);
if (hasProblem()) {
Message.debug("problem : " + problem.getMessage());
return false;
}
DependencyDescriptor dd = getDependencyDescriptor(parent);
if (dd != null) {
usage.addUsage(rootModuleConf, dd, parentConf);
}
return loaded;
}
use of org.apache.ivy.plugins.resolver.DependencyResolver in project ant-ivy by apache.
the class ResolveTest method testResolveDualChain.
@Test
public void testResolveDualChain() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(ResolveTest.class.getResource("dualchainresolverconf.xml"));
DependencyResolver resolver = ivy.getSettings().getResolver("default");
assertNotNull(resolver);
assertTrue(resolver instanceof DualResolver);
// first without cache
ivy.resolve(ResolveTest.class.getResource("ivy-dualchainresolver.xml"), getResolveOptions(new String[] { "default" }));
assertTrue(new File("build/cache/xerces/xerces/ivy-2.6.2.xml").exists());
assertTrue(new File("build/cache/xerces/xerces/jars/xmlParserAPIs-2.6.2.jar").exists());
assertTrue(new File("build/cache/xerces/xerces/jars/xercesImpl-2.6.2.jar").exists());
// second with cache for ivy file only
new File("build/cache/xerces/xerces/jars/xmlParserAPIs-2.6.2.jar").delete();
new File("build/cache/xerces/xerces/jars/xercesImpl-2.6.2.jar").delete();
assertFalse(new File("build/cache/xerces/xerces/jars/xmlParserAPIs-2.6.2.jar").exists());
assertFalse(new File("build/cache/xerces/xerces/jars/xercesImpl-2.6.2.jar").exists());
ivy.resolve(ResolveTest.class.getResource("ivy-dualchainresolver.xml"), getResolveOptions(new String[] { "default" }));
assertTrue(new File("build/cache/xerces/xerces/ivy-2.6.2.xml").exists());
assertTrue(new File("build/cache/xerces/xerces/jars/xmlParserAPIs-2.6.2.jar").exists());
assertTrue(new File("build/cache/xerces/xerces/jars/xercesImpl-2.6.2.jar").exists());
}
use of org.apache.ivy.plugins.resolver.DependencyResolver in project ant-ivy by apache.
the class ConfigureTest method testTypedefWithCustomClasspath.
@Test
public void testTypedefWithCustomClasspath() throws Exception {
Ivy ivy = new Ivy();
ivy.setVariable("ivy.custom.test.dir", new File("test/java/org/apache/ivy/core/settings").toURI().toURL().toString());
ivy.configure(ConfigureTest.class.getResource("ivysettings-custom-typedef.xml"));
DependencyResolver custom = ivy.getSettings().getResolver("custom");
assertNotNull(custom);
assertEquals("org.apache.ivy.plugins.resolver.CustomResolver", custom.getClass().getName());
}
use of org.apache.ivy.plugins.resolver.DependencyResolver in project ant-ivy by apache.
the class ConfigureTest method testDefault14.
@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);
}
use of org.apache.ivy.plugins.resolver.DependencyResolver in project ant-ivy by apache.
the class ConfigureTest method testDefault.
@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());
}
Aggregations