Project-specific task override issue


(Evgeny Ulyanov) #1

Hi everyone.

I’m trying to add some project-specific functionality - I want the jar task for specific projects to work different from default. That’s the part of build.gradle from my root project:

project(":Common") {
    task jar (overwrite: true) << { println "Replaced task" }

    jar.dependsOn classesJar
    jar.dependsOn resourcesJar
    jar.dependsOn configJar
}

The ‘classesJar’, ‘resourcesJar’ and ‘configJar’ are defined inside the subprojects part.

And when I run gradle jar from the subproject directory - everything is fine. But when I run gradle build it executes the default jar task.

What am I doing wrong?