A recursive task search in plugin.apply causes early evaluation of subprojects.
I was having an issue in a multiproject build where a subproject's app was not copying lib jars into the .app.
Finally, I tracked down the cause. The following block in MacAppBundle.groovy needs to be put inside a project.afterEvaluate block:
if (Os.isFamily(Os.FAMILY_MAC)) {
project.getTasksByName("assemble", true).each{ t -> t.dependsOn(dmgTask) }
} else {
project.getTasksByName("assemble", true).each{ t -> t.dependsOn(zipTask) }
}
Putting this inside an afterEvaluate solved all my problems. I guess the recursive task search forces an early evaluation of subprojects. Then when addCopyToLibTask() is called this block doesn't get called in the subproject since its already evaluated.
My solution feels like more of a workaround though. Shouldn't gradle execute project.afterEvaluate blocks for projects that were already evaluated before? I did a lot of testing and it seems that afterEvaluate must be called before the project is evaluated...
A recursive task search in plugin.apply causes early evaluation of subprojects.
I was having an issue in a multiproject build where a subproject's app was not copying lib jars into the .app.
Finally, I tracked down the cause. The following block in MacAppBundle.groovy needs to be put inside a
project.afterEvaluate
block:Putting this inside an
afterEvaluate
solved all my problems. I guess the recursive task search forces an early evaluation of subprojects. Then whenaddCopyToLibTask()
is called this block doesn't get called in the subproject since its already evaluated.My solution feels like more of a workaround though. Shouldn't gradle execute
project.afterEvaluate
blocks for projects that were already evaluated before? I did a lot of testing and it seems thatafterEvaluate
must be called before the project is evaluated...