Execute task after subproject execution

Hi All, this would seem to be a simple concept to pull off but I’m scratching my head on how it’s done. I have a root project with a variety of subprojects. Each subproject uses the java plugin to build, compile and create jar artifacts. After all of these are done I’d like for a task defined on the root project to be executed. Any ideas on how this is done?

Thanks!

There’s probably a more elegant way to solve this by tapping into the action of a lifecycle task. In other words, you could call build or assemble in the parent project (which has an action in it) which would execute after all the jars are complete.

If you really wanted, you could tie into the task graph and inject a task into the graph at the very end. (http://gradle.org/docs/current/userguide/tutorial_using_tasks.html#configure-by-dag)

Thanks Seth,

So I’m still not certain where my hook is for applying my task. The last executions of my build are for the last subproject in my build. My parent project, named ‘core’, runs through its phases (not showing all for brevity):

… core:compileJava core:processResources core:classes … core:build

then after that my child projects run

core:commons:compileJava core:commons:processResources

But I never see any subsequent execution of the ‘core’ project itself. It seems gradle loops through the subprojects and leaves me with no hook to do anything after that.

So I’ve found my own clean way to do this, a real obvious solution, simply define the task in my parent gradle file and execute it:

gradle clean build deploy

deploy will now be tacked onto the end of the build cycle. This works perfect for me :slight_smile: