Sorry about this lengthy question, it really is a simple as the title suggests, but I wanted to provide an example and rational it.
According to the tutorial a running a task on a dependent project will first trigger the same task on the depended-on project. For my java projects this works for compileJava but not for clean or my own tasks.
I tested with the following project
Structure:
pro/
settings.gradle
build.gradle
a/
b/
settings.gradle:
include 'a', 'b'
build.gradle:
configure(subprojects) {
apply plugin: 'java'
task mytask { }
}
configure(project(':b')) {
dependencies {
compile project(':a')
}
}
gradle b:compileJava
gives
Executing command: "b:compileJava"
:a:compileJava UP-TO-DATE
:a:processResources UP-TO-DATE
:a:classes UP-TO-DATE
:a:jar UP-TO-DATE
:b:compileJava UP-TO-DATE
BUILD SUCCESSFUL
Total time: 3.089 secs
Completed Successfully
I.e, the same named task on a is called before the requested task on b. (Actually I expected only the compileJava but not processResources, classes and jar, since compileJava doesn’t depend on them. (Is this behaviour in the documentation?)).
but
gradle b:clean
gives
Executing command: "b:clean"
:b:clean
BUILD SUCCESSFUL
Total time: 2.892 secs
Completed Successfully
That is, a:clean is not called first as I expected from the tutorial. Same with ‘mytask’:
Executing command: "b:mytask"
:b:mytask UP-TO-DATE
BUILD SUCCESSFUL
Total time: 2.936 secs
Completed Successfully
Do I need to explicitly set cross project dependencies between same named tasks on dependent projects or is there a simpler way to achieve this.
My actual usecase is a deploy task that is supposed to trigger compile…deploy (if needed) on depended-on tasks before deploying the requested project. E.g.
gradle b:deploy
should trigger deploy on a first and all it’s requisite tasks.