Skip to content

Commit 4fd2e6e

Browse files
committed
build: read version properties before the root version tasks run
getPackageVersion and getCommitVersion looked up -PpackageVersion, -PpreReleaseVersion and -PgitCommitVersion through Task.project inside doLast, which Gradle 9 deprecates and Gradle 10 rejects. They are now read when the tasks are configured.
1 parent 47d2e9e commit 4fd2e6e

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎build.gradle‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ def getCCacheVersion = { ->
8080
}
8181

8282
task getPackageVersion {
83+
def packageVersion = findProperty("packageVersion")
84+
def preReleaseVersion = findProperty("preReleaseVersion")
85+
8386
doLast {
8487
String content = new File("$rootDir/package.json").getText("UTF-8")
8588
def jsonSlurper = new JsonSlurper()
@@ -89,14 +92,14 @@ task getPackageVersion {
8992

9093
println "Using runtime version from package.json '${pVersion}'"
9194

92-
if (project.hasProperty("packageVersion") && packageVersion != "") {
95+
if (packageVersion != null && packageVersion != "") {
9396
pVersion += "-" + packageVersion
9497

9598
println "Using packageVersion property '${pVersion}'"
9699
}
97100

98101

99-
if (project.hasProperty("preReleaseVersion")) {
102+
if (preReleaseVersion != null) {
100103
pVersion += "-" + preReleaseVersion
101104

102105
println "Adding preReleaseVersion property '${pVersion}' to package version"
@@ -111,8 +114,10 @@ task getPackageVersion {
111114
}
112115

113116
task getCommitVersion {
117+
def gitCommitVersion = findProperty("gitCommitVersion")
118+
114119
doLast {
115-
if (project.hasProperty("gitCommitVersion")) {
120+
if (gitCommitVersion != null) {
116121
println "Using commit version property " + gitCommitVersion
117122
arVersion = gitCommitVersion
118123
} else if ("$System.env.GIT_COMMIT" != "null") {

0 commit comments

Comments
 (0)