Print external dependencies

Hi!

I want to make a task that prints all external dependecies of a multi project build.

This example is what I have so far:

task(printExtDepends) {
 subprojects.each {
  p -> p.dependencies.each {d -> println d}
 }
}

when I run this task i get several lines of output that looks like this:

org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler@4da4c8
.
.
.

Where do I go from here? Am I doing it the wrong way?

I solved it, starting to get my head around gradle :slight_smile:

I’ll paste the code here. If anyone has a better solution, please let me know. The task prints all projects with compile time snapshot dependencies for all subprojects.

Here it is:

task(printSnapshotDependencies) << {
 def snapshotsPerProject = new HashMap<Project, List>();
 for(project in subprojects) {
  def dependencies = project.configurations.compile.getDependencies()
  dependencies.matching{dependency -> dependency.version.toLowerCase().contains("snapshot")}.each { snapshot ->
   if(snapshotsPerProject.containsKey(project)) {
    snapshotsPerProject.get(project).add(snapshot)
   } else {
    def listOfSnapshots = new ArrayList();
    listOfSnapshots.add(snapshot);
    snapshotsPerProject.put(project, listOfSnapshots)
   }
  }
 }
 snapshotsPerProject.keySet().each {
  project -> println "\n" + project.getPath()
  snapshotsPerProject.get(project).each { snapshot ->
   println "\t" + snapshot.getGroup() + ":" + snapshot.getName() + ":" + snapshot.getVersion();
  }
 }
}