Resolve all artifacts and variants of a dependency

Hello,

I need to fetch all artifacts and variants of all dependencies of my project. For example if I have a Java library as dependency, I must fetch its Jar, sources and javadoc. To do this, I am using the Artifact View API and it works, but I have a lot of different dependencies, which can contain jar, zip or other custom artifacts, so I have to define Artifact Views for all types of dependencies. It makes the code more complex to maintain, so I would like to simplify it.

Is there an alternative option to Artifact View, does Gradle provides an API allowing to fetch all artifacts and variants of a dependency?

You cannot even list the variants of an arbitrary dependencies through some task, except by forcing an ambiguity error between all variants and reading the error message: Please provide a way to list variants of dependencies · Issue #19226 · gradle/gradle · GitHub

So no, I don’t think there is some programmatic way to list all variants.

Additionally, for non-GMM publications there are some variants derived out of thin air, for GMM you could look into the GMM.
But either way, there could also always be additional artifacts with classifiers that are not modeled as proper feature variant artifacts in the GMM so even if there were a way to list all variants you would miss those.

OK, so I will keep my current solution for now and try to improve it.

Thanks for your answer.

1 Like