I have a number of java subprojects under one root project, and I would like to gather all the compiled test classes in the subprojects and make one big JAR out of them.
The following discussion provides a good starting point but I can not seem to get it to work:
I tried doing something like this in the root project build.gradle:
Is there anyone willing to explain why? It is because I can only access project tasks after the evaluation phase?
How does evaluationDependsOn( subproject.path ) affect evaluation order?
You are not restricted from accessing the project tasks during the configuration phase, but there is still an evaluation ordering dependency. Gradle is executing the code in your build script to create the model, but you can’t reference a value until it has been created. By default, Gradle evaluates from the root down to children, in order alphanumerically at each level. Therefore, the testClasses task does not exist in the subprojects until after the root project has been evaluated.
The line you reference forces the project evaluation to be postponed until after the evaluation of the project specified. If your case just needs the evaluation to depend on child projects, you can likely simplify this line to use evaluationDependsOnChildren() instead.