How do I know where a task came from in gradle?

I have a complex gradle build system that I inherited. It works very well, but includes several plugins (java, groovy, antlr, jacoco, jetty, etc.). I couldn't figure out how to achieve something, so I ran "./gradlew tasks -all". It turns out that a "generated" task was executed (it re-generated the antlr based code). Great, but it took a long time and I had no idea.

Where did this task generation come from? What gradle command can I use to figure out where this task comes from? There were custom antlr tasks that have "dependOn" generate, so I think it comes from the antlr plugin, but it's hard to tell.

+3


source to share


1 answer


It is currently not possible to find all tasks for a given plugin, nor can you specify a plugin for a given task. Please see the docs - there is no connection between the task and the plugin.

You can try the following piece of code (it might be error prone):



import java.lang.reflect.Modifier

project.plugins.each { p ->
    println "Plugin: ${p.getClass().name} "
    p.getClass().declaredFields.findAll { 
        Modifier.isStatic(it.getModifiers()) && 
        it.name.endsWith('_TASK_NAME') &&
        it.type.simpleName.equals('String')
    }.each {
        println " -> ${it.get(p)}"
    }
    println '\n'
}

      

0


source







All Articles