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

1

6

I have a complicated gradle build system that I inherited. It works pretty well, but includes multiple plugins (java, groovy, antlr, jacoco, jetty, etc.). I could not figure out how to accomplish something, so I did a './gradlew tasks --all'. It turns out that there was a 'generate' task that did it (it re-generated the antlr-based code). Great, but it took a long time, and I had no idea.

Where did that generate task come from? What gradle command can I use to figure out where that task came from? There was a custom antlr tasks that has a 'dependsOn 'generate', so I would think that it is coming from the antlr plugin, but it's hard to tell.

Dorie answered 18/9, 2014 at 14:5 Comment(0)
E
0

Currently it's not possible the find all tasks for a given plugin as well as specify a plugin for a given task. Please view the docs - there's no link between a task and a plugin.

You may 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'
}
Eucalyptol answered 18/9, 2014 at 14:48 Comment(1)
Is that what You're looking for?Eucalyptol

© 2022 - 2024 — McMap. All rights reserved.