I am (again) facing a problem using gradle. I have a multi project with project A and B. Both projects create a WAR file, and the war task depends on an other task:
When I executed the war task in a subproject, the hello task always prints the build directory of the root.
$> gradle projectA:war
$> hello build/
It never prints projectA/build or projectB/build. I find this very irritating, because the hello task is executed within different projects and therefore I expect different build directories.
Is there a way to get the actual build directory of the subproject?
Looking at the script snippet above, it looks like you are defining the hello task on the root project, rather than the subprojects (I assume the script is the root project’s build.gradle). If those are the only subprojects in your build, then something like the following should work:
A task defined on the root project is just that (a task defined on the root project), so it will print
out the buildDir of the root project.
So, what you did originally was create a task that prints out the buildDir of the root project, and then made your the various war tasks on your project depend on that one task. So it will have printed the buildDir of the root project and it will have only printed once.
what you actually want to do is create a task for each subproject that will print the buildDir of that subproject.