[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aether-users] Resolving source and javadoc attachments
|
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