org.apache.ivy.plugins.resolver.util.ResolvedResource Java Examples
The following examples show how to use
org.apache.ivy.plugins.resolver.util.ResolvedResource.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BasicResolver.java From ant-ivy with Apache License 2.0 | 6 votes |
@Override public ArtifactDownloadReport download(final ArtifactOrigin origin, DownloadOptions options) { Checks.checkNotNull(origin, "origin"); return getRepositoryCacheManager().download(origin.getArtifact(), new ArtifactResourceResolver() { public ResolvedResource resolve(Artifact artifact) { try { Resource resource = getResource(origin.getLocation()); if (resource != null) { String revision = origin.getArtifact().getModuleRevisionId().getRevision(); return new ResolvedResource(resource, revision); } } catch (IOException e) { Message.debug(e); } return null; } }, downloader, getCacheDownloadOptions(options)); }
Example #2
Source File: IBiblioResolver.java From ant-ivy with Apache License 2.0 | 6 votes |
@Override public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data) { if (!isM2compatible() || !isUsepoms()) { return null; } ModuleRevisionId mrid = dd.getDependencyRevisionId(); mrid = convertM2IdForResourceSearch(mrid); final String revision = dd.getDependencyRevisionId().getRevision(); final MavenTimedSnapshotVersionMatcher.MavenSnapshotRevision snapshotRevision = MavenTimedSnapshotVersionMatcher.computeIfSnapshot(revision); if (snapshotRevision != null) { final ResolvedResource rres = findSnapshotDescriptor(dd, data, mrid, snapshotRevision); if (rres != null) { return rres; } } return findResourceUsingPatterns(mrid, getIvyPatterns(), DefaultArtifact.newPomArtifact(mrid, data.getDate()), getRMDParser(dd, data), data.getDate()); }
Example #3
Source File: LocalFileRepositoryCacheManager.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public ResolvedModuleRevision cacheModuleDescriptor(DependencyResolver resolver, ResolvedResource resolvedResource, DependencyDescriptor dd, Artifact moduleArtifact, ResourceDownloader downloader, CacheMetadataOptions options) throws ParseException { if (!moduleArtifact.isMetadata()) { return null; } assert resolvedResource.getResource().isLocal(); File file = new File(resolvedResource.getResource().getName()); assert file.isFile(); ArtifactOrigin origin = new ArtifactOrigin(moduleArtifact, true, file.getAbsolutePath()); MetadataArtifactDownloadReport report = new MetadataArtifactDownloadReport(moduleArtifact); report.setDownloadStatus(DownloadStatus.NO); report.setArtifactOrigin(origin); report.setSize(file.length()); report.setLocalFile(file); report.setSearched(false); report.setOriginalLocalFile(file); ModuleDescriptor descriptor = parseModuleDescriptor(resolver, moduleArtifact, options, file, resolvedResource.getResource()); return new ResolvedModuleRevision(resolver, resolver, descriptor, report); }
Example #4
Source File: IBiblioResolver.java From ant-ivy with Apache License 2.0 | 6 votes |
@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); }
Example #5
Source File: CacheResolver.java From ant-ivy with Apache License 2.0 | 6 votes |
@Override public DownloadReport download(Artifact[] artifacts, DownloadOptions options) { ensureConfigured(); clearArtifactAttempts(); DownloadReport dr = new DownloadReport(); for (Artifact artifact : artifacts) { final ArtifactDownloadReport adr = new ArtifactDownloadReport(artifact); dr.addArtifactReport(adr); ResolvedResource artifactRef = getArtifactRef(artifact, null); if (artifactRef != null) { Message.verbose("\t[NOT REQUIRED] " + artifact); ArtifactOrigin origin = new ArtifactOrigin(artifact, true, artifactRef .getResource().getName()); File archiveFile = ((FileResource) artifactRef.getResource()).getFile(); adr.setDownloadStatus(DownloadStatus.NO); adr.setSize(archiveFile.length()); adr.setArtifactOrigin(origin); adr.setLocalFile(archiveFile); } else { adr.setDownloadStatus(DownloadStatus.FAILED); } } return dr; }
Example #6
Source File: BasicResolver.java From ant-ivy with Apache License 2.0 | 6 votes |
private void resolveAndCheckRevision(ModuleDescriptor systemMd, ModuleRevisionId dependencyConstraint, ResolvedResource ivyRef, boolean isDynamic) { // we get the resolved module revision id from the descriptor: it may contain extra // attributes that were not included in the dependency constraint ModuleRevisionId resolvedMrid = systemMd.getResolvedModuleRevisionId(); if (resolvedMrid.getRevision() == null || resolvedMrid.getRevision().length() == 0 || resolvedMrid.getRevision().startsWith("working@")) { if (!isDynamic) { resolvedMrid = ModuleRevisionId.newInstance(resolvedMrid, dependencyConstraint.getRevision()); } else if (ivyRef == null) { resolvedMrid = systemMd.getMetadataArtifact().getModuleRevisionId(); } else if (ivyRef.getRevision() == null || ivyRef.getRevision().length() == 0) { resolvedMrid = ModuleRevisionId.newInstance(resolvedMrid, "working@" + getName()); } else { resolvedMrid = ModuleRevisionId.newInstance(resolvedMrid, ivyRef.getRevision()); } } if (isDynamic) { Message.verbose("\t\t[" + toSystem(resolvedMrid).getRevision() + "] " + dependencyConstraint.getModuleId()); } systemMd.setResolvedModuleRevisionId(resolvedMrid); checkModuleDescriptorRevision(systemMd, dependencyConstraint); }
Example #7
Source File: BasicResolver.java From ant-ivy with Apache License 2.0 | 6 votes |
private ModuleRevisionId getRevision(ResolvedResource ivyRef, ModuleRevisionId askedMrid, ModuleDescriptor md) { Map<String, String> allAttributes = new HashMap<>(); allAttributes.putAll(md.getQualifiedExtraAttributes()); allAttributes.putAll(askedMrid.getQualifiedExtraAttributes()); String revision = ivyRef.getRevision(); if (revision == null) { Message.debug("no revision found in reference for " + askedMrid); if (getSettings().getVersionMatcher().isDynamic(askedMrid)) { if (md.getModuleRevisionId().getRevision() == null) { revision = "working@" + getName(); } else { Message.debug("using " + askedMrid); revision = askedMrid.getRevision(); } } else { Message.debug("using " + askedMrid); revision = askedMrid.getRevision(); } } return ModuleRevisionId.newInstance(askedMrid.getOrganisation(), askedMrid.getName(), askedMrid.getBranch(), revision, allAttributes); }
Example #8
Source File: RepositoryResolver.java From ant-ivy with Apache License 2.0 | 6 votes |
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; } }
Example #9
Source File: BasicResolver.java From ant-ivy with Apache License 2.0 | 6 votes |
protected ResourceMDParser getRMDParser(final DependencyDescriptor dd, final ResolveData data) { return new ResourceMDParser() { public MDResolvedResource parse(Resource resource, String rev) { try { ResolvedModuleRevision rmr = BasicResolver.this.parse(new ResolvedResource( resource, rev), dd, data); if (rmr != null) { return new MDResolvedResource(resource, rev, rmr); } } catch (ParseException e) { Message.warn("Failed to parse the file '" + resource + "'", e); } return null; } }; }
Example #10
Source File: FileSystemResolverTest.java From ant-ivy with Apache License 2.0 | 6 votes |
/** * Test case for IVY-676. * * @throws Exception if something goes wrong * @see <a href="https://issues.apache.org/jira/browse/IVY-676">IVY-676</a> */ @Test public void testFindIvyFileRefWithMultipleIvyPatterns() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); resolver.setSettings(settings); resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/multi-ivypattern/ivy1/ivy-[revision].xml"); resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/multi-ivypattern/ivy2/ivy-[revision].xml"); ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0+"); ResolvedResource ivyRef = resolver.findIvyFileRef(new DefaultDependencyDescriptor(mrid, false), data); // check that the found ivy file is the one from the first pattern! assertEquals( new File("test/repositories/multi-ivypattern/ivy1/ivy-1.0.xml").getCanonicalPath(), new File(ivyRef.getResource().getName()).getCanonicalPath()); }
Example #11
Source File: LocalFileRepositoryCacheManager.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public ResolvedModuleRevision cacheModuleDescriptor(DependencyResolver resolver, ResolvedResource resolvedResource, DependencyDescriptor dd, Artifact moduleArtifact, ResourceDownloader downloader, CacheMetadataOptions options) throws ParseException { if (!moduleArtifact.isMetadata()) { return null; } assert resolvedResource.getResource().isLocal(); File file = new File(resolvedResource.getResource().getName()); assert file.isFile(); ArtifactOrigin origin = new ArtifactOrigin(moduleArtifact, true, file.getAbsolutePath()); MetadataArtifactDownloadReport report = new MetadataArtifactDownloadReport(moduleArtifact); report.setDownloadStatus(DownloadStatus.NO); report.setArtifactOrigin(origin); report.setSize(file.length()); report.setLocalFile(file); report.setSearched(false); report.setOriginalLocalFile(file); ModuleDescriptor descriptor = parseModuleDescriptor(resolver, moduleArtifact, options, file, resolvedResource.getResource()); return new ResolvedModuleRevision(resolver, resolver, descriptor, report); }
Example #12
Source File: AbstractPatternsBasedResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data) { ModuleRevisionId mrid = dd.getDependencyRevisionId(); if (isM2compatible()) { mrid = convertM2IdForResourceSearch(mrid); } return findResourceUsingPatterns(mrid, ivyPatterns, DefaultArtifact.newIvyArtifact(mrid, data.getDate()), getRMDParser(dd, data), data.getDate()); }
Example #13
Source File: TestFixture.java From ant-ivy with Apache License 2.0 | 5 votes |
public File getIvyFile(String mrid) { ResolvedResource r = getTestRepository().findIvyFileRef( new DefaultDependencyDescriptor(ModuleRevisionId.parse(mrid), false), TestHelper.newResolveData(getSettings())); if (r == null) { throw new IllegalStateException("module not found: " + mrid); } return ((FileResource) r.getResource()).getFile(); }
Example #14
Source File: AbstractOSGiResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
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; }
Example #15
Source File: AbstractOSGiResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
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; }
Example #16
Source File: DownloadingRepositoryCacheManager.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public ResolvedModuleRevision cacheModuleDescriptor(DependencyResolver resolver, final ResolvedResource resolvedResource, DependencyDescriptor dd, Artifact moduleArtifact, ResourceDownloader downloader, CacheMetadataOptions options) throws ParseException { if (!moduleArtifact.isMetadata()) { return null; } ArtifactResourceResolver artifactResourceResolver = new ArtifactResourceResolver() { public ResolvedResource resolve(Artifact artifact) { return resolvedResource; } }; ArtifactDownloadReport report = download(moduleArtifact, artifactResourceResolver, downloader, new CacheDownloadOptions().setListener(options.getListener()).setForce(true)); if (report.getDownloadStatus() == DownloadStatus.FAILED) { LOGGER.warn("problem while downloading module descriptor: {}: {} ({} ms)", resolvedResource.getResource(), report.getDownloadDetails(), report.getDownloadTimeMillis()); return null; } ModuleDescriptor md = parseModuleDescriptor(resolver, moduleArtifact, options, report.getLocalFile(), resolvedResource.getResource()); LOGGER.debug("\t{}: parsed downloaded md file for {}; parsed={}" + getName(), moduleArtifact.getModuleRevisionId(), md.getModuleRevisionId()); MetadataArtifactDownloadReport madr = new MetadataArtifactDownloadReport(md.getMetadataArtifact()); madr.setSearched(true); madr.setDownloadStatus(report.getDownloadStatus()); madr.setDownloadDetails(report.getDownloadDetails()); madr.setArtifactOrigin(report.getArtifactOrigin()); madr.setDownloadTimeMillis(report.getDownloadTimeMillis()); madr.setOriginalLocalFile(report.getLocalFile()); madr.setSize(report.getSize()); return new ResolvedModuleRevision(resolver, resolver, md, madr); }
Example #17
Source File: IBiblioResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
private ResolvedResource findSnapshotArtifact(final Artifact artifact, final Date date, final ModuleRevisionId mrid, final MavenTimedSnapshotVersionMatcher.MavenSnapshotRevision snapshotRevision) { if (!isM2compatible()) { return null; } final String snapshotArtifactPattern; if (snapshotRevision.isTimestampedSnapshot()) { Message.debug(mrid + " has been identified as a (Maven) timestamped snapshot revision"); // this is a Maven timestamped snapshot revision. Something like 1.0.0-<timestampedRev> // We now get the base revision from it, which is "1.0.0" and append the "-SNAPSHOT" to it. final String inferredSnapshotRevision = snapshotRevision.getBaseRevision() + "-SNAPSHOT"; // we replace the "/[revision]" in the descriptor pattern with the "inferred" snapshot // revision which is like "1.0.0-SNAPSHOT". Ultimately, this will translate to // something like // org/module/1.0.0-SNAPSHOT/artifact-1.0.0-<timestampedRev>(-[classifier]).ext snapshotArtifactPattern = getWholePattern().replaceFirst("/\\[revision\\]", "/" + inferredSnapshotRevision); } else { // it's not a timestamped revision, but a regular snapshot. Try and find any potential // timestamped revisions of this regular snapshot, by looking into the Maven metadata final String timestampedRev = findTimestampedSnapshotVersion(mrid); if (timestampedRev == null) { // no timestamped snapshots found and instead this is just a regular snapshot // version. So let's just fallback to our logic of finding resources using // configured artifact pattern(s) return null; } Message.verbose(mrid + " has been identified as a snapshot revision which has a timestamped snapshot revision " + timestampedRev); // we have found a timestamped revision for a snapshot. So we replace the "-[revision]" // in the artifact file name to use the timestamped revision. // Ultimately, this will translate to something like // org/module/1.0.0-SNAPSHOT/artifact-1.0.0-<timestampedRev>(-[classifier]).ext snapshotArtifactPattern = getWholePattern().replaceFirst("\\-\\[revision\\]", "-" + timestampedRev); } return findResourceUsingPattern(mrid, snapshotArtifactPattern, artifact, getDefaultRMDParser(artifact .getModuleRevisionId().getModuleId()), date); }
Example #18
Source File: IBiblioResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
private ResolvedResource findSnapshotDescriptor(final DependencyDescriptor dd, final ResolveData data, final ModuleRevisionId mrid, final MavenTimedSnapshotVersionMatcher.MavenSnapshotRevision snapshotRevision) { if (!isM2compatible()) { return null; } final String snapshotDescriptorPattern; if (snapshotRevision.isTimestampedSnapshot()) { Message.debug(mrid + " has been identified as a (Maven) timestamped snapshot revision"); // this is a Maven timestamped snapshot revision. Something like 1.0.0-<timestampedRev> // We now get the base revision from it, which is "1.0.0" and append the "-SNAPSHOT" to it. final String inferredSnapshotRevision = snapshotRevision.getBaseRevision() + "-SNAPSHOT"; // we replace the "/[revision]" in the descriptor pattern with the "inferred" snapshot // revision which is like "1.0.0-SNAPSHOT". // Ultimately, this will translate to something like // org/module/1.0.0-SNAPSHOT/artifact-1.0.0-<timestampedRev>(-[classifier]).ext snapshotDescriptorPattern = getWholePattern().replaceFirst("/\\[revision\\]", "/" + inferredSnapshotRevision); } else { // it's not a timestamped revision, but a regular snapshot. Try and find any potential // timestamped revisions of this regular snapshot, by looking into the Maven metadata final String timestampedRev = findTimestampedSnapshotVersion(mrid); if (timestampedRev == null) { // no timestamped snapshots found and instead this is just a regular snapshot // version. So let's just fallback to our logic of finding resources using // configured Ivy pattern(s) return null; } Message.verbose(mrid + " has been identified as a snapshot revision which has a timestamped snapshot revision " + timestampedRev); // we have found a timestamped revision for a snapshot. So we replace the "-[revision]" // in the artifact file name to use the timestamped revision. // Ultimately, this will translate to something like // org/module/1.0.0-SNAPSHOT/artifact-1.0.0-<timestampedRev>(-[classifier]).ext snapshotDescriptorPattern = getWholePattern().replaceFirst("\\-\\[revision\\]", "-" + timestampedRev); } // find the descriptor using the snapshot descriptor pattern return findResourceUsingPattern(mrid, snapshotDescriptorPattern, DefaultArtifact.newPomArtifact(mrid, data.getDate()), getRMDParser(dd, data), data.getDate()); }
Example #19
Source File: PackagerCacheEntry.java From ant-ivy with Apache License 2.0 | 5 votes |
/** * Get a built artifact. * * @param artifact ditto * @return ResolvedResource * @throws IllegalStateException * if this entry's built has not (yet) completed successfully */ public ResolvedResource getBuiltArtifact(Artifact artifact) { if (!this.built) { throw new IllegalStateException("build in directory `" + this.dir + "' has not yet successfully completed"); } return new ResolvedResource(new BuiltFileResource(this.dir, artifact), this.mr.getRevision()); }
Example #20
Source File: DownloadingRepositoryCacheManager.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public ResolvedModuleRevision cacheModuleDescriptor(DependencyResolver resolver, final ResolvedResource resolvedResource, DependencyDescriptor dd, Artifact moduleArtifact, ResourceDownloader downloader, CacheMetadataOptions options) throws ParseException { if (!moduleArtifact.isMetadata()) { return null; } ArtifactResourceResolver artifactResourceResolver = new ArtifactResourceResolver() { public ResolvedResource resolve(Artifact artifact) { return resolvedResource; } }; ArtifactDownloadReport report = download(moduleArtifact, artifactResourceResolver, downloader, new CacheDownloadOptions().setListener(options.getListener()).setForce(true)); if (report.getDownloadStatus() == DownloadStatus.FAILED) { LOGGER.warn("problem while downloading module descriptor: {}: {} ({} ms)", resolvedResource.getResource(), report.getDownloadDetails(), report.getDownloadTimeMillis()); return null; } ModuleDescriptor md = parseModuleDescriptor(resolver, moduleArtifact, options, report.getLocalFile(), resolvedResource.getResource()); LOGGER.debug("\t{}: parsed downloaded md file for {}; parsed={}" + getName(), moduleArtifact.getModuleRevisionId(), md.getModuleRevisionId()); MetadataArtifactDownloadReport madr = new MetadataArtifactDownloadReport(md.getMetadataArtifact()); madr.setSearched(true); madr.setDownloadStatus(report.getDownloadStatus()); madr.setDownloadDetails(report.getDownloadDetails()); madr.setArtifactOrigin(report.getArtifactOrigin()); madr.setDownloadTimeMillis(report.getDownloadTimeMillis()); madr.setOriginalLocalFile(report.getLocalFile()); madr.setSize(report.getSize()); return new ResolvedModuleRevision(resolver, resolver, md, madr); }
Example #21
Source File: AbstractPatternsBasedResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
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; } }
Example #22
Source File: AbstractPatternsBasedResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
@Override public ResolvedResource findResource(ResolvedResource[] rress, ResourceMDParser rmdparser, ModuleRevisionId mrid, Date date) { if (isM2compatible()) { // convert 'M2'-organisation back to 'Ivy'-organisation mrid = convertM2ResourceSearchIdToNormal(mrid); } return super.findResource(rress, rmdparser, mrid, date); }
Example #23
Source File: AbstractPatternsBasedResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
@Override public ResolvedResource findArtifactRef(Artifact artifact, Date date) { ModuleRevisionId mrid = artifact.getModuleRevisionId(); if (isM2compatible()) { mrid = convertM2IdForResourceSearch(mrid); } return findResourceUsingPatterns(mrid, artifactPatterns, artifact, getDefaultRMDParser(artifact.getModuleRevisionId().getModuleId()), date); }
Example #24
Source File: ChainResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data) { for (DependencyResolver resolver : chain) { ResolvedResource result = resolver.findIvyFileRef(dd, data); if (result != null) { return result; } } return null; }
Example #25
Source File: AbstractOSGiResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
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()]); }
Example #26
Source File: BasicResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
protected ResolvedResource findFirstArtifactRef(ModuleDescriptor md, DependencyDescriptor dd, ResolveData data) { for (String configName : md.getConfigurationsNames()) { for (Artifact artifact : md.getArtifacts(configName)) { ResolvedResource ret = getArtifactRef(artifact, data.getDate()); if (ret != null) { return ret; } } } return null; }
Example #27
Source File: BasicResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
protected long getPublicationDate(ModuleDescriptor md, DependencyDescriptor dd, ResolveData data) { if (md.getPublicationDate() != null) { return md.getPublicationDate().getTime(); } ResolvedResource artifactRef = findFirstArtifactRef(md, dd, data); if (artifactRef != null) { return artifactRef.getLastModified(); } return -1; }
Example #28
Source File: BasicResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
private void cacheModuleDescriptor(ModuleDescriptor systemMd, ModuleRevisionId systemMrid, ResolvedResource ivyRef, ResolvedModuleRevision rmr) { RepositoryCacheManager cacheManager = getRepositoryCacheManager(); final ModuleDescriptorParser parser = systemMd.getParser(); // the metadata artifact which was used to cache the original metadata file Artifact requestedMetadataArtifact = (ivyRef == null) ? systemMd.getMetadataArtifact() : parser.getMetadataArtifact( ModuleRevisionId.newInstance(systemMrid, systemMd.getRevision()), ivyRef.getResource()); cacheManager.originalToCachedModuleDescriptor(this, ivyRef, requestedMetadataArtifact, rmr, new ModuleDescriptorWriter() { public void write(ResolvedResource originalMdResource, ModuleDescriptor md, File src, File dest) throws IOException, ParseException { if (originalMdResource == null) { // a basic ivy file is written containing default data XmlModuleDescriptorWriter.write(md, dest); } else { // copy and update ivy file from source to cache parser.toIvyFile(new FileInputStream(src), originalMdResource.getResource(), dest, md); long repLastModified = originalMdResource.getLastModified(); if (repLastModified > 0) { dest.setLastModified(repLastModified); } } } }); }
Example #29
Source File: BasicResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
private void checkNotConvertedExclusionRule(ModuleDescriptor systemMd, ResolvedResource ivyRef, ResolveData data) { if (!getNamespace().equals(Namespace.SYSTEM_NAMESPACE) && !systemMd.isDefault() && data.getSettings().logNotConvertedExclusionRule() && systemMd instanceof DefaultModuleDescriptor) { DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) systemMd; if (dmd.isNamespaceUseful()) { Message.warn("the module descriptor " + ivyRef.getResource() + " has information which can't be converted into the system namespace. It will require the availability of the namespace '" + getNamespace().getName() + "' to be fully usable."); } } }
Example #30
Source File: BasicResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
@Override public ArtifactOrigin locate(Artifact artifact) { ArtifactOrigin origin = getRepositoryCacheManager().getSavedArtifactOrigin( toSystem(artifact)); if (!ArtifactOrigin.isUnknown(origin)) { return origin; } ResolvedResource artifactRef = getArtifactRef(artifact, null); if (artifactRef != null && artifactRef.getResource().exists()) { return new ArtifactOrigin(artifact, artifactRef.getResource().isLocal(), artifactRef .getResource().getName()); } return null; }