use of org.apache.ivy.plugins.resolver.util.ResolvedResource 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.plugins.resolver.util.ResolvedResource in project ant-ivy by apache.
the class IBiblioResolver method findArtifactRef.
@Override
public ResolvedResource findArtifactRef(Artifact artifact, Date date) {
ensureConfigured(getSettings());
ModuleRevisionId mrid = artifact.getModuleRevisionId();
if (isM2compatible()) {
mrid = convertM2IdForResourceSearch(mrid);
}
final String revision = artifact.getId().getRevision();
final MavenTimedSnapshotVersionMatcher.MavenSnapshotRevision snapshotRevision = MavenTimedSnapshotVersionMatcher.computeIfSnapshot(revision);
if (snapshotRevision != null) {
final ResolvedResource rres = findSnapshotArtifact(artifact, date, mrid, snapshotRevision);
if (rres != null) {
return rres;
}
}
return findResourceUsingPatterns(mrid, getArtifactPatterns(), artifact, getDefaultRMDParser(artifact.getModuleRevisionId().getModuleId()), date);
}
use of org.apache.ivy.plugins.resolver.util.ResolvedResource in project ant-ivy by apache.
the class AbstractPatternsBasedResolver method findResourceUsingPatterns.
protected ResolvedResource findResourceUsingPatterns(ModuleRevisionId moduleRevision, List<String> patternList, Artifact artifact, ResourceMDParser rmdparser, Date date) {
List<ResolvedResource> resolvedResources = new ArrayList<>();
Set<String> foundRevisions = new HashSet<>();
boolean dynamic = getSettings().getVersionMatcher().isDynamic(moduleRevision);
for (String pattern : patternList) {
ResolvedResource rres = findResourceUsingPattern(moduleRevision, pattern, artifact, rmdparser, date);
if (rres != null && !foundRevisions.contains(rres.getRevision())) {
// only add the first found ResolvedResource for each revision
foundRevisions.add(rres.getRevision());
resolvedResources.add(rres);
if (!dynamic) {
// stop iterating if we are not searching a dynamic revision
break;
}
}
}
if (resolvedResources.size() > 1) {
ResolvedResource[] rress = resolvedResources.toArray(new ResolvedResource[resolvedResources.size()]);
return findResource(rress, rmdparser, moduleRevision, date);
} else if (resolvedResources.size() == 1) {
return resolvedResources.get(0);
} else {
return null;
}
}
use of org.apache.ivy.plugins.resolver.util.ResolvedResource in project ant-ivy by apache.
the class RepositoryResolver method findDynamicResourceUsingPattern.
private ResolvedResource findDynamicResourceUsingPattern(ResourceMDParser rmdparser, ModuleRevisionId mrid, String pattern, Artifact artifact, Date date) {
String name = getName();
logAttempt(IvyPatternHelper.substitute(pattern, ModuleRevisionId.newInstance(mrid, IvyPatternHelper.getTokenString(IvyPatternHelper.REVISION_KEY)), artifact));
ResolvedResource[] rress = listResources(repository, mrid, pattern, artifact);
if (rress == null) {
Message.debug("\t" + name + ": unable to list resources for " + mrid + ": pattern=" + pattern);
return null;
} else {
ResolvedResource found = findResource(rress, rmdparser, mrid, date);
if (found == null) {
Message.debug("\t" + name + ": no resource found for " + mrid + ": pattern=" + pattern);
}
return found;
}
}
Aggregations