Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aether-users] Resolving source and javadoc attachments

Thanks Benjamin, makes sense. I will give it a go. With regards to the exception handling, I had already seen this behavior and added code to deal with it:

https://github.com/grails/grails-core/blob/master/grails-aether/src/main/groovy/org/codehaus/groovy/grails/resolve/maven/aether/AetherDependencyManager.groovy#L248

With the 2 step resolve though this will need changing and will probably be less error prone than the above.

Thanks for the help!


On Fri, Jan 18, 2013 at 8:36 PM, Benjamin Bentmann <bentmann@xxxxxxxxxxxx> wrote:
Graeme Rocher wrote:

What I'm having trouble with though is figuring out how to resolve
sources/javadoc attachments for dependencies. If I simply attach an
additional dependency like this:

         if (includeJavadoc) {
             def javadocArtifact = new DefaultArtifact(artifact.groupId,
artifact.artifactId, "javadoc", artifact.extension, artifact.version)
             aetherDependencies << dependency.setArtifact(javadocArtifact)
         }

This works, but transitive dependencies do not get their javadocs resolved.
How do I request that for an entire graph of dependencies I want all of the
javadocs as well?

It's really a 2-step process: You first resolve/collect the actual artifacts, then fire off another batch request to get any attachments.

E.g. say you use a DependencyRequest to resolve the main artifacts, you would then iterate the DependencyResult.getArtifactResults(), create one or more ArtifactRequests for the corresponding attachments, and eventually pass all these ArtifactRequests to RepositorySystem.resolveArtifacts().

Some things to watch out for:
- It's non uncommon that source/javadoc attachments are missing, so that call to resolveArtifacts() is likely going to throw a ArtifactResolutionException. Calling getResults() on that exception will get you the results, much like as if all artifacts were resolved in the first place.
- The sources for test JARs use the classifier "test-sources", i.e. it's not always just the classifier "sources" or "javadoc".


Benjamin
_______________________________________________
aether-users mailing list
aether-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aether-users



--
Graeme Rocher
Grails Project Lead
SpringSource - A Division of VMware
http://www.springsource.com

Back to the top