configure(allprojects) {
group = 'abc.def'
version = appVersion
gradle.taskGraph.whenReady { taskGraph ->
if(taskGraph.hasTask(release)) {
version += '-RELEASE'
} else {
version += '-SNAPSHOT'
}
}
}
The important thing to note is this. Firstly, applying the gradle.taskGraph.whenReady inside allprojects and it appears that the gradle.taskGraph.whenReady is evaulated after allprojects have been configured. You will note that I set the version to be appVersion first (which is 3.6.0), then after the evaluation, the version changes to 3.6.0-RELEASE (or -SNAPSHOT).
I’ve tested this out with my sub projects and each WAR now has either abc-3.6.0-RELEASE.war or abc-3.6.0-SNAPSHOT.war appended correctly.