I’m struggling with following scenario. I have several subprojects which use ‘java’ plugin. settings.gradle
include 'subA', 'subB', 'subC'
Root project has single task called ‘build’, but it doesn’t use ‘java’ plugin.
task build() << {
dependsOn subprojects.build
println 'I should be visible after subprojects are built'
}
If I run ‘build’ task from root project, Gradle will call ‘build’ tasks on subprojects, resulting to following output (pseudo)
I should be visible after subprojects are built
:subA:compileJava
:subA:processResources
:subA:classes
:subA:jar
:subB:compileJava
... etc. ...
What I don’t understand is, why is the “I should be visible after subprojects are built” message printed BEFORE subprojects are built? Can anyone provide some hints about this? I’ve went through documentation, but I didn’t find anything useful there.
You have ‘dependsOn’ in a task action, not in your task configuration. (The ‘<<’ operator is shorthand for task.doLast {}). So your root project build task doesn’t do what you expect.
Well, that actually doesn’t work. I get following error message:
Could not find property 'build' on project ':subA'.
I saw your solution on several other forums/webs though. But this error line confuses me. I’m using Gradle 1.4, perhaps it’s something that had been changed in this release?
It’s still doesn’t work with “evaluationDependsOnChildren();” in root project. However, I think I didn’t express my problem clearly. What I’m trying to do here, is to create sort of “aggregation” task which would simply take results of sub-project task execution, and aggregate them into one place. At the same time, I wanted to leverage “build” task name, which by default, gradle runs also on all sub-projects. Sub-projects are java projects, so each have it’s own “build” task.
Therefore, I really don’t want to declare this task in configuration phase. Can you please advice me some clever way how to achieve this?