Resolve multi-projects dependencies

(Stéphane Nicoll) #1

I am trying to build a report task similar to ‘org.gradle.api.tasks.diagnostics.DependencyReportTask’ except that I want to generate a file that gives, for each module, the list of dependencies with: groupId, artifactId, version and scope.

Right now a simple CSV will do. I have built the plugin and it produces something that does almost what I want except that I have a lot of dependencies that are unresolved: ‘null’ for the group and version and ‘unspecified’ for the artifact.

I understand we need to go to the resolvedConfiguration to get resolvedDependencies. But I don’t find the information that I want in this model.

Which API should I use? Is there an easy way to filter the internal dependencies from the list (i.e. the modules of the project that another module depends on).


(Benjamin Muschko) #2

A good starting point is to have a look at the resolution result. Unfortunately, you can’t resolve the artifact (yet). The following example shows the use for the ‘compile’ configuration.

task printDependencies << {
    def result = configurations.compile.incoming.resolutionResult
    def externalComponents = result.root.dependencies.selected.findAll { instanceof ModuleComponentIdentifier }
      externalComponents.each { externalComponent ->

(Carlo Luib-Finetti) #3

Interesting version, but I get an error using it (using Gradle 1.9):

> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve com.github.ben-manes:gradle-versions-plugin:0.1.
     Required by:
      > Could not GET '
         > Permission denied: connect

(Benjamin Muschko) #4

What exactly are you referring to with this output?

(Carlo Luib-Finetti) #5

I never noticed this (“Could not resolve com.github.ben-manes:gradle-versions-plugin:0.1.”) and I cannot see, why this plugin is needed. I just wanted to try the task.