commit 6b27dd42075a24591aed00d34c67b23b26e9f65a
parent 609d1d21483eead185cba22e3dea4f239de2a19e
Author: Antoine A <>
Date: Tue, 22 Jul 2025 10:44:53 +0200
common: use build time constant for CLI version
Diffstat:
3 files changed, 30 insertions(+), 21 deletions(-)
diff --git a/build.gradle b/build.gradle
@@ -52,22 +52,12 @@ ext.getVersionWithGitHash = { ->
return "v${project.version}-git-$gitHash"
}
-task versionFile() {
- doLast {
- new File("${projectDir}/common/src/main/resources", "version.txt").text = getVersionWithGitHash()
- }
-}
-
task libeufinVersion {
doLast {
println getVersionWithGitHash()
}
}
-classes {
- dependsOn versionFile
-}
-
dependencies {
dokka(project(":common:"))
dokka(project(":bank:"))
diff --git a/common/build.gradle b/common/build.gradle
@@ -13,7 +13,36 @@ java {
compileKotlin.kotlinOptions.jvmTarget = "17"
compileTestKotlin.kotlinOptions.jvmTarget = "17"
-sourceSets.main.java.srcDirs = ["src/main/kotlin"]
+task versionConstant {
+ def outputDir = file("$buildDir/generated/constants")
+ def outputFile = new File(outputDir, "CompileConstants.kt")
+
+ outputs.dir outputDir
+
+ doLast {
+ // Ensure output directory exists
+ outputDir.mkdirs()
+
+ // Generate the Kotlin constants file
+ outputFile.text = """
+ package tech.libeufin.common
+
+ val VERSION: String = "${getVersionWithGitHash()}"
+ """.stripIndent()
+ }
+}
+
+clean {
+ delete "$buildDir/generated"
+}
+
+
+sourceSets.main.java.srcDirs = ["src/main/kotlin", "$buildDir/generated/constants"]
+
+
+compileKotlin {
+ dependsOn versionConstant
+}
dependencies {
implementation("org.slf4j:slf4j-api:2.0.17")
diff --git a/common/src/main/kotlin/Config.kt b/common/src/main/kotlin/Config.kt
@@ -19,16 +19,6 @@
package tech.libeufin.common
-/**
- * Putting those values into the 'attributes' container because they
- * are needed by the util routines that do NOT have Sandbox and Nexus
- * as dependencies, and therefore cannot access their global variables.
- *
- * Note: putting Sandbox and Nexus as Utils dependencies would result
- * into circular dependency.
- */
-val VERSION: String = "v1.0.8"
-
sealed interface ServerConfig {
data class Unix(val path: String, val mode: Int): ServerConfig
data class Tcp(val addr: String, val port: Int): ServerConfig