I’m trying to use the researchgate gradle-release plugin. I have my versions of certain libraries set in gradle.properties, like so
version=0.14.0
commonVersion=0.15.0-SNAPSHOT
enterpriseVersion=0.16.0-SNAPSHOT
I need to remove the snapshot, so I’ve written a task
tasks {
register("snapshotIncrementer") {
group = "release"
inputs.file("gradle.properties")
outputs.file("gradle.properties")
doFirst {
val file = File("$projectDir/gradle.properties")
val newLines = file.readLines().map { it.replace("-SNAPSHOT", "") }
file.writeText(newLines.joinToString(separator = "\n"))
exec {
setIgnoreExitValue(true)
commandLine("git", "commit", "-m", "Removing SNAPSHOT versions", "--", "gradle.properties")
}
}
doLast {
Thread.sleep(20000)
}
}
"checkSnapshotDependencies" {
dependsOn("snapshotIncrementer")
}
}
That runs before the gradle-release plugin checks if snapshot versions are present. This succeeds in committing the gradle.properties file with the -SNAPSHOT removed, but no matter how long I Thread.sleep for, when the checkSnapshotDependencies task runs, it still sees the old version of the file. I am not sure why this would be unless gradle is doing some sort of optimizing and starting the second task thread before the snapshotIncrementer is done. Any ideas what I can do to get this working?
address-validation on gradle [⇡] via 💎 v2.5.3 on 🐳 v18.06.1
➜ ./gradlew checkSnapshotDependencies -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=0.13.0 -Prelease.newVersion=0.14.0-SNAPSHOT
<-------------> 0% EXECUT
> Task :snapshotIncrementer:snapshotIncrementer
[gradle c2373c0] Removing SNAPSHOT versions
1 file changed, 2 insertions(+), 2 deletions(-)
> Task :checkSnapshotDependencies FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':checkSnapshotDependencies'.
> Snapshot dependencies detected:
address-validation: [com.promontech.enterprise:pt-enterprise-dependencies:0.16.0-SNAPSHOT, com.promontech.loanplatform:pt-lp-common:0.15.0-SNAPSHOT]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.2/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 21s
2 actionable tasks: 2 executed
This waits 20 seconds and then continues, yet the gradle.properties file is still seen with the SNAPSHOT versions in it.