use of org.apache.ivy.core.cache.ArtifactOrigin in project ant-ivy by apache.
the class IvyArtifactReport method writeOriginLocationIfPresent.
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");
}
}
use of org.apache.ivy.core.cache.ArtifactOrigin in project ant-ivy by apache.
the class PomModuleDescriptorParser method addSourcesAndJavadocArtifactsIfPresent.
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");
}
}
}
}
use of org.apache.ivy.core.cache.ArtifactOrigin in project ant-ivy by apache.
the class BasicResolver method locate.
@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;
}
use of org.apache.ivy.core.cache.ArtifactOrigin in project ant-ivy by apache.
the class XmlReportWriter method outputMetadataArtifact.
private void outputMetadataArtifact(PrintWriter out, IvyNode dep) {
if (dep.getModuleRevision() != null) {
MetadataArtifactDownloadReport madr = dep.getModuleRevision().getReport();
out.print("\t\t\t\t<metadata-artifact");
out.print(" status=\"" + XMLHelper.escape(madr.getDownloadStatus().toString()) + "\"");
out.print(" details=\"" + XMLHelper.escape(madr.getDownloadDetails()) + "\"");
out.print(" size=\"" + madr.getSize() + "\"");
out.print(" time=\"" + madr.getDownloadTimeMillis() + "\"");
if (madr.getLocalFile() != null) {
out.print(" location=\"" + XMLHelper.escape(madr.getLocalFile().getAbsolutePath()) + "\"");
}
out.print(" searched=\"" + madr.isSearched() + "\"");
if (madr.getOriginalLocalFile() != null) {
out.print(" original-local-location=\"" + XMLHelper.escape(madr.getOriginalLocalFile().getAbsolutePath()) + "\"");
}
ArtifactOrigin origin = madr.getArtifactOrigin();
if (origin != null) {
out.print(" origin-is-local=\"" + String.valueOf(origin.isLocal()) + "\"");
out.print(" origin-location=\"" + XMLHelper.escape(origin.getLocation()) + "\"");
}
out.println("/>");
}
}
use of org.apache.ivy.core.cache.ArtifactOrigin in project ant-ivy by apache.
the class XmlReportWriter method outputArtifacts.
private void outputArtifacts(ConfigurationResolveReport report, PrintWriter out, IvyNode dep) {
out.println("\t\t\t\t<artifacts>");
for (ArtifactDownloadReport adr : report.getDownloadReports(dep.getResolvedId())) {
out.print("\t\t\t\t\t<artifact name=\"" + XMLHelper.escape(adr.getName()) + "\" type=\"" + XMLHelper.escape(adr.getType()) + "\" ext=\"" + XMLHelper.escape(adr.getExt()) + "\"");
out.print(extraToString(adr.getArtifact().getExtraAttributes(), SEPARATOR));
out.print(" status=\"" + XMLHelper.escape(adr.getDownloadStatus().toString()) + "\"");
out.print(" details=\"" + XMLHelper.escape(adr.getDownloadDetails()) + "\"");
out.print(" size=\"" + adr.getSize() + "\"");
out.print(" time=\"" + adr.getDownloadTimeMillis() + "\"");
if (adr.getLocalFile() != null) {
out.print(" location=\"" + XMLHelper.escape(adr.getLocalFile().getAbsolutePath()) + "\"");
}
if (adr.getUnpackedLocalFile() != null) {
out.print(" unpackedFile=\"" + XMLHelper.escape(adr.getUnpackedLocalFile().getAbsolutePath()) + "\"");
}
ArtifactOrigin origin = adr.getArtifactOrigin();
if (origin != null) {
out.println(">");
out.println("\t\t\t\t\t\t<origin-location is-local=\"" + String.valueOf(origin.isLocal()) + "\"" + " location=\"" + XMLHelper.escape(origin.getLocation()) + "\"/>");
out.println("\t\t\t\t\t</artifact>");
} else {
out.println("/>");
}
}
out.println("\t\t\t\t</artifacts>");
}
Aggregations