project('projectA') {
task A(dependsOn: ':projectB:B') << {
println 'Hello from A'
}
}
project('projectB') {
task B << {
println 'Hello from B'
}
}
To refer to a task in another project, you prefix the name of the task with the path of the project it belongs to :projectB:B
.
And the output is:
> gradle -q B
Hello from A
Hello from B