Gradle tasks dependency tree


(Victor Martinez) #1

Hi there,

Just seen the below project: https://code.google.com/p/gradle-script-visualizer, which is a great idea but i’ts a bit odd the way of parsing gradle scripts:

Does it exist another way of running the same process within Gradle a part of the ‘gradle tasks --all’?

I’ve used the below gradle script:

...
gradle.taskGraph.whenReady {
    taskGraph ->
         println project.name
       taskGraph.getAllTasks().each {
           print "task : " + it.path
          if ( ! it.getDependsOn().isEmpty() ){
               print " depends : "
               StringBuilder builder = new StringBuilder();
               it.getDependsOn().each { dep ->
                   if ( dep != null && dep.toString().startsWith("task") ) {
                       if (builder.length() != 0) {
                           builder.append(",");
                       }
                       builder.append(dep.path)
                   }
               }
               print builder.toString()
           }
           println ""
       }
}

TBH, I don’t like it at all, you need to specify the list of tasks you will execute in order to generate the GAD it properly.

Any clues?

Thanks