Index: IvyResolveJob.java =================================================================== --- IvyResolveJob.java (revision 763498) +++ IvyResolveJob.java (working copy) @@ -43,6 +43,7 @@ import org.apache.ivy.core.event.resolve.EndResolveDependencyEvent; import org.apache.ivy.core.event.resolve.StartResolveDependencyEvent; import org.apache.ivy.core.module.descriptor.Artifact; +import org.apache.ivy.core.module.descriptor.DefaultArtifact; import org.apache.ivy.core.module.descriptor.ModuleDescriptor; import org.apache.ivy.core.module.id.ModuleRevisionId; import org.apache.ivy.core.report.ArtifactDownloadReport; @@ -502,6 +503,9 @@ private Path getSourcesArtifactPath(ArtifactDownloadReport adr, Collection all, Map/* */dependencies) { + + Path sourcePath = null; + Artifact artifact = adr.getArtifact(); monitor.subTask("searching sources for " + artifact); for (Iterator iter = all.iterator(); iter.hasNext();) { @@ -514,6 +518,9 @@ return new Path(otherAdr.getLocalFile().getAbsolutePath()); } } + + + // we haven't found source artifact in resolved artifacts, // let's look in the module declaring the artifact IvyNode node = (IvyNode) dependencies.get(artifact.getId().getModuleRevisionId()); @@ -532,11 +539,33 @@ } } } + + Map extraAttribs = new HashMap(); + extraAttribs.put("m:classifier", "sources"); + sourcePath = getPathForSpecifiedClassifier(artifact, extraAttribs); + return sourcePath; + } + + private Path getPathForSpecifiedClassifier(Artifact artifact, Map extraAttribs) { + Collection source = conf.getInheritedSourceTypes(); + for (Iterator iterator = source.iterator(); iterator.hasNext();) { + String conf = (String) iterator.next(); + + Artifact metaArtifact = new DefaultArtifact(artifact.getModuleRevisionId(), + artifact.getPublicationDate(), artifact.getName(), conf, artifact.getExt(), extraAttribs); + + ArtifactDownloadReport metaAdr = ivy.getResolveEngine().download(metaArtifact, + new DownloadOptions()); + if (metaAdr.getLocalFile() != null && metaAdr.getLocalFile().exists()) { + return new Path(metaAdr.getLocalFile().getAbsolutePath()); + } + } return null; } private Path getJavadocArtifactPath(ArtifactDownloadReport adr, Collection all, Map/* */dependencies) { + Path javaDocPath = null; Artifact artifact = adr.getArtifact(); monitor.subTask("searching javadoc for " + artifact); for (Iterator iter = all.iterator(); iter.hasNext();) { @@ -567,7 +596,10 @@ } } } - return null; + Map extraAttribs = new HashMap(); + extraAttribs.put("m:classifier", "javadoc"); + javaDocPath = getPathForSpecifiedClassifier(artifact, extraAttribs); + return javaDocPath; } private IPath getSourceAttachment(Path classpathArtifact, Path sourcesArtifact) {