Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I alias gradle task as if it were called with -x parameter?

Tags:

gradle

I want instead of gradle cleanIdea idea -x compileJava -x compileTestJava call something like gradle ideaNoRecompile

like image 837
guai Avatar asked Sep 26 '22 15:09

guai


1 Answers

You can use TaskExecutionGraph to do it. First of all, you need to provide a custom task, named ideaNoRecompile, when during the configuration phase, you need to check, whether this graph contains ideaNoRecompile task (that means, that this task will be executed. And if this task should be executed, then you can use a closгre to skip all the tasks, you don't want to be executed. Something like this:

task ideaNoRecompile(dependsOn:idea) {
    gradle.taskGraph.whenReady { graph ->
        if (graph.hasTask(ideaNoRecompile)) {
            compileJava.enabled = false
            compileTestJava.enabled = false
        }
    }
}
like image 67
Stanislav Avatar answered Oct 18 '22 07:10

Stanislav