The idea I had until now was to add a new task that ensure that version == lastVersion during a release:
release {
buildTasks = ['doRelease']
}
task doRelease {
dependsOn(
'checkLastVersionValue',
// other release tasks
)
}
task checkLastVersionValue {
doLast {
if(version.endsWith('SNAPSHOT')) {
throw new GradleException("version '$version' ends with SNAPSHOT, this is not a release build!")
}
if(lastVersion != version) {
throw new GradleException("lastVersion '$lastVersion' does not match version '$version', fix it in the 'gradle.properties' file.")
}
}
}
This is not perfect, but I least I will not forget to fix the value prior to a release.
In my
gradle.properties
I want to keep trace of theversion
(example1.6.0-SNAPSHOT
) and the last released versionlastVersion
(example1.5.3
).This allows me to use the
lastVersion
in different places (docs, baseline definition).I am wondering if the release plugin could help me. Ideally:
The first commit:
[PATCH] [Gradle Release Plugin] - pre tag commit: '1.6.0'.
Would update both values:
The second commit:
[Gradle Release Plugin] - new version commit: '1.6.1-SNAPSHOT'.
The idea I had until now was to add a new task that ensure that
version
==lastVersion
during a release:This is not perfect, but I least I will not forget to fix the value prior to a release.