-
Notifications
You must be signed in to change notification settings - Fork 115
Expand file tree
/
Copy pathincrement-version.gradle.kts
More file actions
23 lines (20 loc) · 946 Bytes
/
increment-version.gradle.kts
File metadata and controls
23 lines (20 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
* If the current version is not a snapshot version, this task will update the version by one
* patch level, append "-SNAPSHOT", and replace the old version in the gradle.properties file.
*/
tasks.register("incrementVersion") {
doLast {
if (version.toString().endsWith("-SNAPSHOT")) {
return@doLast
}
val splitVersion = version.toString().split(".")
val newVersion = "${splitVersion[0]}.${splitVersion[1]}.${splitVersion[2].toInt() + 1}-SNAPSHOT"
file("gradle.properties").writeText(
file("gradle.properties").readText().replace(version.toString(), newVersion)
)
file("base/src/main/java/org/bstats/MetricsBase.java").writeText(
file("base/src/main/java/org/bstats/MetricsBase.java").readText()
.replace("METRICS_VERSION = \"${version.toString()}\";", "METRICS_VERSION = \"${newVersion}\";")
)
}
}