I have a multi-project build with three projects: a
, b
, and c
.
They’re all configured by the root build.gradle
, which looks like this:
allprojects {
project.afterEvaluate {
task canary
}
}
If I run gradlew canary
, I get this output:
:canary UP-TO-DATE
:a:canary UP-TO-DATE
:b:canary UP-TO-DATE
:c:canary UP-TO-DATE
Not too shocking. Now, let’s say I change my build.gradle
, as such:
project(':a') {
evaluationDependsOn(':b')
evaluationDependsOn(':c')
}
allprojects {
project.afterEvaluate {
task canary
}
}
Now, when I run gradlew canary
, I only get this:
:canary UP-TO-DATE
:a:canary UP-TO-DATE
It’s as though the canary task never existed for b and c, and there are no warnings.
But, if I put the allprojects
block at the top, then everything goes back to working as expected. This is all in gradle 3.3.
I spent a couple hours banging on this issue, but the evaluationDependsOn
and afterEvaluate
blocks were in plugin code, so it was pretty difficult to figure out what was going on.
I sort of understand how a
is causing b
and c
to eagerly evaluate, but I don’t understand why b
and c
don’t get to finish their own evaluation first. If there’s no way to fix this issue, it seems there should at least be a loud warning when someone makes an afterEvaluate
call which will never execute.