use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class URLResolverTest method testLatestFile.
@Test
public void testLatestFile() throws Exception {
URLResolver resolver = new URLResolver();
resolver.setSettings(settings);
String rootpath = new File("test/repositories/1").toURI().toURL().toExternalForm();
resolver.addIvyPattern(rootpath + "[organisation]/[module]/ivys/ivy-[revision].xml");
resolver.addArtifactPattern(rootpath + "[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
resolver.setName("test");
assertEquals("test", resolver.getName());
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "2.0");
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org1", "mod1.1", "latest.integration"), false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
Date pubdate = new GregorianCalendar(2005, 1, 15, 11, 0, 0).getTime();
assertEquals(pubdate, rmr.getPublicationDate());
}
use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class PomModuleDescriptorParser method addTo.
private void addTo(PomModuleDescriptorBuilder mdBuilder, PomDependencyMgt dep, ParserSettings ivySettings) throws ParseException, IOException {
if ("import".equals(dep.getScope())) {
ModuleRevisionId importModRevID = ModuleRevisionId.newInstance(dep.getGroupId(), dep.getArtifactId(), dep.getVersion());
ResolvedModuleRevision importModule = parseOtherPom(ivySettings, importModRevID);
if (importModule == null) {
throw new IOException("Impossible to import module for " + mdBuilder.getModuleDescriptor().getResource().getName() + ". Import=" + importModRevID);
}
ModuleDescriptor importDescr = importModule.getDescriptor();
// add dependency management info from imported module
for (PomDependencyMgt importedDepMgt : getDependencyManagements(importDescr)) {
mdBuilder.addDependencyMgt(new DefaultPomDependencyMgt(importedDepMgt.getGroupId(), importedDepMgt.getArtifactId(), importedDepMgt.getVersion(), importedDepMgt.getScope(), importedDepMgt.getExcludedModules()));
}
} else {
mdBuilder.addDependencyMgt(dep);
}
}
use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class CacheResolver method getDependency.
@Override
public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data) throws ParseException {
clearIvyAttempts();
ModuleRevisionId mrid = dd.getDependencyRevisionId();
// check revision
ResolvedModuleRevision rmr = getRepositoryCacheManager().findModuleInCache(dd, mrid, getCacheOptions(data), null);
if (rmr != null) {
Message.verbose("\t" + getName() + ": revision in cache: " + mrid);
return rmr;
} else if (!getSettings().getVersionMatcher().isDynamic(mrid)) {
Message.verbose("\t" + getName() + ": no ivy file in cache found for " + mrid);
return null;
} else {
ensureConfigured();
ResolvedResource ivyRef = findIvyFileRef(dd, data);
if (ivyRef != null) {
Message.verbose("\t" + getName() + ": found ivy file in cache for " + mrid);
Message.verbose("\t\t=> " + ivyRef);
ModuleRevisionId resolvedMrid = ModuleRevisionId.newInstance(mrid, ivyRef.getRevision());
IvyNode node = data.getNode(resolvedMrid);
if (node != null && node.getModuleRevision() != null) {
// this revision has already be resolved : return it
Message.verbose("\t" + getName() + ": revision already resolved: " + resolvedMrid);
return node.getModuleRevision();
}
rmr = getRepositoryCacheManager().findModuleInCache(dd.clone(ModuleRevisionId.newInstance(dd.getDependencyRevisionId(), ivyRef.getRevision())), dd.getDependencyRevisionId(), getCacheOptions(data), null);
if (rmr != null) {
Message.verbose("\t" + getName() + ": revision in cache: " + resolvedMrid);
return rmr;
} else {
Message.error("\t" + getName() + ": inconsistent cache: clean it and resolve again");
return null;
}
} else {
Message.verbose("\t" + getName() + ": no ivy file in cache found for " + mrid);
return null;
}
}
}
use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class AbstractResolver method checkLatest.
protected ResolvedModuleRevision checkLatest(DependencyDescriptor dd, ResolvedModuleRevision newModuleFound, ResolveData data) {
Checks.checkNotNull(dd, "dd");
Checks.checkNotNull(data, "data");
// always cache dynamic mrids because we can store per-resolver values
saveModuleRevisionIfNeeded(dd, newModuleFound);
// check if latest is asked and compare to return the most recent
ResolvedModuleRevision previousModuleFound = data.getCurrentResolvedModuleRevision();
String newModuleDesc = describe(newModuleFound);
Message.debug("\tchecking " + newModuleDesc + " against " + describe(previousModuleFound));
if (previousModuleFound == null) {
Message.debug("\tmodule revision kept as first found: " + newModuleDesc);
return newModuleFound;
} else if (isAfter(newModuleFound, previousModuleFound, data.getDate())) {
Message.debug("\tmodule revision kept as younger: " + newModuleDesc);
return newModuleFound;
} else if (!newModuleFound.getDescriptor().isDefault() && previousModuleFound.getDescriptor().isDefault()) {
Message.debug("\tmodule revision kept as better (not default): " + newModuleDesc);
return newModuleFound;
} else {
Message.debug("\tmodule revision discarded as older: " + newModuleDesc);
return previousModuleFound;
}
}
Aggregations