use of org.apache.ivy.plugins.resolver.util.ResolvedResource in project ant-ivy by apache.
the class AbstractOSGiResolver method findIvyFileRef.
public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data) {
ModuleRevisionId mrid = dd.getDependencyRevisionId();
String osgiType = mrid.getOrganisation();
if (osgiType == null) {
throw new RuntimeException("Unsupported OSGi module Id: " + mrid.getModuleId());
}
String id = mrid.getName();
Collection<ModuleDescriptor> mds = ModuleDescriptorWrapper.unwrap(getRepoDescriptor().findModules(osgiType, id));
if (mds == null || mds.isEmpty()) {
Message.verbose("\t " + id + " not found.");
return null;
}
ResolvedResource[] ret;
if (BundleInfo.BUNDLE_TYPE.equals(osgiType)) {
ret = findBundle(dd, data, mds);
} else {
ret = findCapability(dd, data, mds);
}
ResolvedResource found = findResource(ret, getDefaultRMDParser(dd.getDependencyId()), mrid, data.getDate());
if (found == null) {
Message.debug("\t" + getName() + ": no resource found for " + mrid);
}
return found;
}
use of org.apache.ivy.plugins.resolver.util.ResolvedResource in project ant-ivy by apache.
the class DefaultRepositoryCacheManagerTest method testLatestIntegrationIsCachedPerResolver.
@Test
@Ignore
public void testLatestIntegrationIsCachedPerResolver() throws Exception {
// given a module org#module
ModuleId mi = new ModuleId("org", "module");
// and a latest.integration mrid/dd
ModuleRevisionId mridLatest = new ModuleRevisionId(mi, "trunk", "latest.integration");
DependencyDescriptor ddLatest = new DefaultDependencyDescriptor(mridLatest, false);
// and some random options
CacheMetadataOptions options = new CacheMetadataOptions().setCheckTTL(false);
// setup resolver1 to download the static content so we can call cacheModuleDescriptor
MockResolver resolver = new MockResolver();
resolver.setName("resolver1");
resolver.setSettings(ivy.getSettings());
ivy.getSettings().addResolver(resolver);
ResourceDownloader downloader = new ResourceDownloader() {
public void download(Artifact artifact, Resource resource, File dest) throws IOException {
String content = "<ivy-module version=\"2.0\"><info organisation=\"org\" module=\"module\" status=\"integration\" revision=\"1.1\" branch=\"trunk\"/></ivy-module>";
dest.getParentFile().mkdirs();
FileOutputStream out = new FileOutputStream(dest);
PrintWriter pw = new PrintWriter(out);
pw.write(content);
pw.flush();
out.close();
}
};
ModuleDescriptorWriter writer = new ModuleDescriptorWriter() {
public void write(ResolvedResource originalMdResource, ModuleDescriptor md, File src, File dest) throws IOException {
XmlModuleDescriptorWriter.write(md, dest);
}
};
// latest.integration will resolve to 1.1 in resolver1
ModuleRevisionId mrid11 = new ModuleRevisionId(mi, "trunk", "1.1");
DefaultArtifact artifact11 = new DefaultArtifact(mrid11, new Date(), "module-1.1.ivy", "ivy", "ivy", true);
DependencyDescriptor dd11 = new DefaultDependencyDescriptor(mrid11, false);
BasicResource resource11 = new BasicResource("/module-1-1.ivy", true, 1, 0, true);
ResolvedResource mdRef11 = new ResolvedResource(resource11, "1.1");
// tell the cache about 1.1
ResolvedModuleRevision rmr11 = cacheManager.cacheModuleDescriptor(resolver, mdRef11, dd11, artifact11, downloader, options);
cacheManager.originalToCachedModuleDescriptor(resolver, mdRef11, artifact11, rmr11, writer);
// and use the new overload that passes in resolver name
cacheManager.saveResolvedRevision("resolver1", mridLatest, "1.1");
ResolvedModuleRevision rmrFromCache = cacheManager.findModuleInCache(ddLatest, mridLatest, options, "resolver1");
assertEquals(rmr11, rmrFromCache);
}
use of org.apache.ivy.plugins.resolver.util.ResolvedResource in project ant-ivy by apache.
the class AbstractOSGiResolver method findCapability.
public ResolvedResource[] findCapability(DependencyDescriptor dd, ResolveData data, Collection<ModuleDescriptor> mds) {
List<ResolvedResource> ret = new ArrayList<>(mds.size());
for (ModuleDescriptor md : mds) {
IvyNode node = data.getNode(md.getModuleRevisionId());
if (node != null && node.getDescriptor() != null) {
// already resolved import, no need to go further
return new ResolvedResource[] { buildResolvedCapabilityMd(dd, node.getDescriptor()) };
}
ret.add(buildResolvedCapabilityMd(dd, md));
}
return ret.toArray(new ResolvedResource[mds.size()]);
}
use of org.apache.ivy.plugins.resolver.util.ResolvedResource in project ant-ivy by apache.
the class AbstractOSGiResolver method findArtifactRef.
@Override
public ResolvedResource findArtifactRef(Artifact artifact, Date date) {
URL url = artifact.getUrl();
if (url == null) {
// not an artifact resolved by this resolver
return null;
}
Message.verbose("\tusing url for " + artifact + ": " + url);
logArtifactAttempt(artifact, url.toExternalForm());
final Resource resource = new URLResource(url, this.getTimeoutConstraint());
return new ResolvedResource(resource, artifact.getModuleRevisionId().getRevision());
}
use of org.apache.ivy.plugins.resolver.util.ResolvedResource in project ant-ivy by apache.
the class AbstractOSGiResolver method findBundle.
public ResolvedResource[] findBundle(DependencyDescriptor dd, ResolveData data, Collection<ModuleDescriptor> mds) {
ResolvedResource[] ret = new ResolvedResource[mds.size()];
int i = 0;
for (ModuleDescriptor md : mds) {
MetadataArtifactDownloadReport report = new MetadataArtifactDownloadReport(null);
report.setDownloadStatus(DownloadStatus.NO);
report.setSearched(true);
ResolvedModuleRevision rmr = new ResolvedModuleRevision(this, this, md, report);
MDResolvedResource mdrr = new MDResolvedResource(null, md.getRevision(), rmr);
ret[i++] = mdrr;
}
return ret;
}
Aggregations