I am trying to develop a “release” task within a multi-project build. This task needs to coordinate the execution of many tasks across all the projects. Essentially I want clean to be the very first task run across all the projects. But thats not what happens. Adding each project’s clean task executes clean in a non-intuative way. For example:
:hibernate-c3p0:clean
:hibernate-c3p0:generatePomFileForMavenJavaPublication
:hibernate-core:generateGrammarSource UP-TO-DATE
:hibernate-core:jaxb UP-TO-DATE
:hibernate-core:generateMainLoggingClasses UP-TO-DATE
:hibernate-core:compileJava UP-TO-DATE
:hibernate-core:processResources UP-TO-DATE
:hibernate-core:classes UP-TO-DATE
:hibernate-core:jar UP-TO-DATE
:hibernate-c3p0:generateMainLoggingClasses
:hibernate-c3p0:compileJava
:hibernate-c3p0:processResources
:hibernate-c3p0:classes
:hibernate-c3p0:jar
:hibernate-c3p0:sourcesJar
:hibernate-c3p0:publishMavenJavaPublicationToJboss-snapshots-repositoryRepository
...
:hibernate-c3p0:publish
:hibernate-testing:generateMainLoggingClasses UP-TO-DATE
:hibernate-testing:compileJava UP-TO-DATE
:hibernate-testing:processResources UP-TO-DATE
:hibernate-testing:classes UP-TO-DATE
:hibernate-testing:jar UP-TO-DATE
:hibernate-c3p0:compileTestJava
:hibernate-c3p0:processTestResources
:hibernate-c3p0:testClasses
:hibernate-c3p0:test
:hibernate-core:clean
:hibernate-core:generatePomFileForMavenJavaPublication
:hibernate-core:sourcesJar
:hibernate-core:publishMavenJavaPublicationToJboss-snapshots-repositoryRepository
Essentially, the jar for the hibernate-core module is “built” (really its just skipped because clean happens later), then hibernate-core is cleaned before Gradle finally tries to publish the artifact it just cleaned.
The “release task” itself is very simple:
task performRelease(type: Task) {
description = "Perform a full set of release steps (sans VCS handling)"
}
All the interesting bits are handled through task dependepncies:
performRelease.dependsOn rootProject.subprojects.findAll{ p -> p.tasks.findByPath("clean") }.tasks.clean
performRelease.dependsOn rootProject.subprojects.findAll{ p -> p.tasks.findByPath("test") }.tasks.test
performRelease.dependsOn rootProject.subprojects.findAll{ p -> p.tasks.findByPath("publish") }.tasks.publish
performRelease.dependsOn uploadDocs
performRelease.dependsOn uploadBundles
But as you can see above from output, this leads to undesireable ordering amongst the dependency tasks.
Perhaps this is related to the recent discussions on the dev mailing list wrt task ordering?