How can I disable a task in build.gradle

前端 未结 4 1962
情歌与酒
情歌与酒 2020-12-15 15:30

I want to skip some tasks when I run gradle build. I know that it can be done from command line with -x:

gradle build -x unwantedTask 
         


        
4条回答
  •  别那么骄傲
    2020-12-15 15:56

    Because I need to disable a bunch of tasks, so I use the following codes before apply plugin: in my build.gradle file:

    tasks.whenTaskAdded {task ->
        if(task.name.contains("unwantedTask")) {
            task.enabled = false
        }
    }
    

提交回复
热议问题