Remove task dependency

I have multi-project build, and one of the modules is a “release project”. It’s main purposue is to create zip using “distributions” plugin

The problem is when I fire “build” on the main project I don’t want distZip task from “distribution” plugin to be executed.
Using “gradle tasks -all” on my release I figured out that distZip task is a dependency of assemble task, which in turn is a dependency to build task.
I’ve tried adding following lines to build.gradle in my “release -project”, but none of them worked(task is still executed)

assemble.deleteAllActions()
build.deleteAllActions()
'build.dependsOn.remove("assemble")' 

def reducedDependencies = build.taskDependencies.values - assemble
    build.dependsOn = reducedDependencies
1 Like

You can disable task execution using enabled property for example
distZip.enabled = false
distTar.enabled = false

And then implement some logic to enable them, for example if you provide some property during run using -Psomeprop your code snippet would look like this

if (!someProp) {
distZip.enabled = false
distTar.enabled = false
}