I’m now trying to develop a gradle plugin which can help analyze dependency problems in Gradle projects. However, i have encountered a problem. I need to download the artifacts of a certain depenendecy which is left unselected because there are dependencies of the same component.
The problem is i need to download and analyze the artifacts of such dependencies to carry on with my project. Is there anything like the ArtifactResolver in Maven , which I provide the GAV coordinates, and it helps me download the artifacts. It would be much of a help to carry me through this problem.
Thansk for your help. But i tried it and found that it used the component id which was actually selected in the resolution process instead of the requested component. Even if i use the ForModule method, it returns with artifactResults of size 0.
I tried to use the api in several ways but they either fail or give the selected version rather than the requested one. There are little example on the internet on how to use it, it’s likely i did something wrong.
So i had to change the way to do it into imitating how it’s done in build.gradle. I add a new configuration and add dependencies to it. It seems to work, but i wonder it has any negative consequences.
Whoops, I’m sorry, I was wrong actually.
You cannot get the code artifact through the ArtifactResolutionQuery.
You can only get the sources, javadoc, pom, and ivy files.
You cannot even get the Gradle Module Metadata, strange.
That your artifacts are empty is because you didn’t request any. JvmLibrary is the component and further arguments to withArtifacts would define which artifacts to get.
So yeah, normal resolution is the way to go.
You can either create normal configurations of this, or you can create “detached configurations”, depending on the concrete use-case.
Thanks for your help! I mistake the JvmLibrary with the artifact that i want.
I notice that detached configurations should be created with dependencies, but the dependencies create need to specify a config name. So which of the two should be created first? I tried to use something like