Skip to content

Commit 7b17297

Browse files
authored
Register a task to store project version (#21)
1 parent 3eaf96d commit 7b17297

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

gradle-modules/src/main/kotlin/org.sonarsource.cloud-native.sonar-plugin.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ val cleanupTask = tasks.register<Delete>("cleanupOldVersion") {
2626
description = "Clean up jars of old plugin version"
2727

2828
delete(
29-
fileTree(project.layout.buildDirectory.dir("libs")).matching {
29+
fileTree(layout.buildDirectory.dir("libs")).matching {
3030
include("${project.name}-*.jar")
3131
exclude("${project.name}-${project.version}-*.jar")
3232
}

gradle-modules/src/main/kotlin/org/sonarsource/cloudnative/gradle/CommonSettingsPlugin.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@ open class CommonSettingsPlugin
4848
}
4949
}
5050

51+
settings.gradle.rootProject {
52+
tasks.register("storeProjectVersion") {
53+
group = "build"
54+
description = "Store the project version in a file to be used in CI caches"
55+
inputs.property("version", this@rootProject.version)
56+
val projectVersionFile =
57+
file(
58+
"${System.getenv(
59+
"CIRRUS_WORKING_DIR"
60+
)}/${System.getenv("PROJECT_VERSION_CACHE_DIR")}/evaluated_project_version.txt"
61+
)
62+
outputs.file(projectVersionFile)
63+
outputs.cacheIf { true }
64+
65+
doLast {
66+
projectVersionFile.writeText(this@rootProject.version.toString())
67+
}
68+
}
69+
}
70+
5171
settings.configureDevelocity()
5272
}
5373

0 commit comments

Comments
 (0)