Java Code Examples for org.apache.ivy.core.cache.ArtifactOrigin#isUnknown()
The following examples show how to use
org.apache.ivy.core.cache.ArtifactOrigin#isUnknown() .
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: IvyArtifactReport.java From ant-ivy with Apache License 2.0 | 6 votes |
private void writeOriginLocationIfPresent(RepositoryCacheManager cache, TransformerHandler saxHandler, ArtifactDownloadReport artifact) throws SAXException { ArtifactOrigin origin = artifact.getArtifactOrigin(); if (!ArtifactOrigin.isUnknown(origin)) { String originName = origin.getLocation(); boolean isOriginLocal = origin.isLocal(); String originLocation; AttributesImpl originLocationAttrs = new AttributesImpl(); if (isOriginLocal) { originLocationAttrs.addAttribute(null, "is-local", "is-local", "CDATA", "true"); originLocation = originName.replace('\\', '/'); } else { originLocationAttrs.addAttribute(null, "is-local", "is-local", "CDATA", "false"); originLocation = originName; } saxHandler .startElement(null, "origin-location", "origin-location", originLocationAttrs); char[] originLocationAsChars = originLocation.toCharArray(); saxHandler.characters(originLocationAsChars, 0, originLocationAsChars.length); saxHandler.endElement(null, "origin-location", "origin-location"); } }
Example 2
Source File: EndArtifactDownloadEvent.java From ant-ivy with Apache License 2.0 | 6 votes |
public EndArtifactDownloadEvent(DependencyResolver resolver, Artifact artifact, ArtifactDownloadReport report, File dest) { super(NAME, artifact); this.resolver = resolver; this.report = report; addAttribute("resolver", this.resolver.getName()); addAttribute("status", this.report.getDownloadStatus().toString()); addAttribute("details", this.report.getDownloadDetails()); addAttribute("size", String.valueOf(this.report.getSize())); addAttribute("file", dest.getAbsolutePath()); addAttribute("duration", String.valueOf(this.report.getDownloadTimeMillis())); ArtifactOrigin origin = report.getArtifactOrigin(); if (!ArtifactOrigin.isUnknown(origin)) { addAttribute("origin", origin.getLocation()); addAttribute("local", String.valueOf(origin.isLocal())); } else { addAttribute("origin", ""); addAttribute("local", ""); } }
Example 3
Source File: IvyPatternHelper.java From ant-ivy with Apache License 2.0 | 5 votes |
public String toString() { if (origin == null) { ModuleRevisionId revId = ModuleRevisionId.newInstance(org, moduleName, branch, revision, extraModuleAttributes); Artifact artifact = new DefaultArtifact(revId, null, artifactName, artifactType, artifactExt, extraArtifactAttributes); // TODO cache: see how we could know which actual cache manager to use, since this // will fail when using a resolver in a chain with a specific cache manager RepositoryCacheManager cacheManager = IvyContext.getContext().getSettings() .getResolver(revId).getRepositoryCacheManager(); origin = cacheManager.getSavedArtifactOrigin(artifact); if (ArtifactOrigin.isUnknown(origin)) { Message.debug("no artifact origin found for " + artifact + " in " + cacheManager); return null; } } if (ArtifactOrigin.isUnknown(origin)) { return null; } // we assume that the original filename is the last part of the original file location String location = origin.getLocation(); int lastPathIndex = location.lastIndexOf('/'); if (lastPathIndex == -1) { lastPathIndex = location.lastIndexOf('\\'); } int lastColonIndex = location.lastIndexOf('.'); return location.substring(lastPathIndex + 1, lastColonIndex); }
Example 4
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; }
Example 5
Source File: ChainResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
@Override public ArtifactOrigin locate(Artifact artifact) { for (DependencyResolver resolver : chain) { ArtifactOrigin origin = resolver.locate(artifact); if (!ArtifactOrigin.isUnknown(origin)) { return origin; } } return ArtifactOrigin.unknown(artifact); }
Example 6
Source File: PomModuleDescriptorParser.java From ant-ivy with Apache License 2.0 | 4 votes |
private void addSourcesAndJavadocArtifactsIfPresent(PomModuleDescriptorBuilder mdBuilder, ParserSettings ivySettings) { if (mdBuilder.getMainArtifact() == null) { // no main artifact in pom, we don't need to search for meta artifacts return; } boolean sourcesLookup = !"false" .equals(ivySettings.getVariable("ivy.maven.lookup.sources")); boolean javadocLookup = !"false" .equals(ivySettings.getVariable("ivy.maven.lookup.javadoc")); if (!sourcesLookup && !javadocLookup) { Message.debug("Sources and javadocs lookup disabled"); return; } ModuleDescriptor md = mdBuilder.getModuleDescriptor(); ModuleRevisionId mrid = md.getModuleRevisionId(); DependencyResolver resolver = ivySettings.getResolver(mrid); if (resolver == null) { Message.debug( "no resolver found for " + mrid + ": no source or javadoc artifact lookup"); } else { ArtifactOrigin mainArtifact = resolver.locate(mdBuilder.getMainArtifact()); if (!ArtifactOrigin.isUnknown(mainArtifact)) { String mainArtifactLocation = mainArtifact.getLocation(); if (sourcesLookup) { ArtifactOrigin sourceArtifact = resolver.locate(mdBuilder.getSourceArtifact()); if (!ArtifactOrigin.isUnknown(sourceArtifact) && !sourceArtifact.getLocation().equals(mainArtifactLocation)) { Message.debug("source artifact found for " + mrid); mdBuilder.addSourceArtifact(); } else { // it seems that sometimes the 'src' classifier is used instead of 'sources' // Cfr. IVY-1138 ArtifactOrigin srcArtifact = resolver.locate(mdBuilder.getSrcArtifact()); if (!ArtifactOrigin.isUnknown(srcArtifact) && !srcArtifact.getLocation().equals(mainArtifactLocation)) { Message.debug("source artifact found for " + mrid); mdBuilder.addSrcArtifact(); } else { Message.debug("no source artifact found for " + mrid); } } } else { Message.debug("sources lookup disabled"); } if (javadocLookup) { ArtifactOrigin javadocArtifact = resolver .locate(mdBuilder.getJavadocArtifact()); if (!ArtifactOrigin.isUnknown(javadocArtifact) && !javadocArtifact.getLocation().equals(mainArtifactLocation)) { Message.debug("javadoc artifact found for " + mrid); mdBuilder.addJavadocArtifact(); } else { Message.debug("no javadoc artifact found for " + mrid); } } else { Message.debug("javadocs lookup disabled"); } } } }