Maven Resolver: Finding the primary artifact’s extension for a GAV

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Maven Resolver: Finding the primary artifact’s extension for a GAV

Andreas Sewe-2

for some analyses of third-party *-tests.jar artifacts I want to build a
test classpath.

My input is an Artifact coordinate like
org.example:example:jar:tests:1.0. I can use this to download the
example-1.0-tests.jar and also to download all test-scoped dependencies
of org.example:example:1.0. Great!

Alas, the test classpath is incomplete without the primary artifact,
which may or may not have the extension "jar". So simply trying to
resolve org.example:example:jar:1.0 won't always work. I may instead
have to look for org.example:example:war:1.0 or some other coordinate.

(FWIW, there are really WARs with *-test.jar in Central [1], so this
isn't a hypothetical problem.)

Now, the question is how to get that extension with the maven-resolver?

Here's what I tried already:

- ArtifactDescriptorResult.getArtifact() simply parrots back the
extension from the request, so if I do a readArtifactDescriptor for
org.example:example:1.0, it always says "jar" (as that is the default).

- I could download the POM, but that would only give me the *packaging*,
not the extension. Also, the set of packagings is extensible, so
hard-coding a mapping may work for common cases like bundle->jar, not is
not a real solution.

Any pointers? Or is what I am after impossible, as there simply is not
enough information in the remote repository to piece this together?

Best wishes,


[1] <>

signature.asc (836 bytes) Download Attachment