Get dependency declaration details


(Joachim Nilsson) #1

We have a project that creates a result resembling a ‘fat jar’, well actually a .deb file containing a ‘lib’ folder.
There is also a build.gradle file including those files as fileTree() dependency declarations.

I want to improve this by replacing it with a local repository (included in a folder installed by the .deb) containing all the files, and replace the dependency declarations with ‘real ones’. All works fine except for one dependency that originally is declared with the specific configuration ‘test’. What is the correct way to see declaration details like ‘ext’, ‘configuration’ etc.? I want to make sure I create the archive and new import correctly.

The original declaration:
testRuntime group: "my.group", name: "theName", version: "1.0", configuration: "test"

My attempt to get the details and the files:
configurations[testRuntime].resolvedConfiguration.resolvedArtifacts.each {ResolvedArtifact artifact -> ModuleVersionIdentifier module = artifact.moduleVersion.id copyArtifactToArchive(module, artifact.file) saveNewDependency("newconfiguration group: '${module.group}', name: '${module.name}', version: '${module.version}, configuration: 'where to find this?' ") }

I know that I can get hold of the Ivy file using the Artifact Query API, but I am not sure how to detect the original declaration in the first place.


(Joachim Nilsson) #2

Give it some time and the solution will be apparent…
The ResolvedArtifact contains all I need:

configuration: '${artifact.configuration}'