Skip to content

Commit 73a8631

Browse files
committed
Update build config task
1 parent 9e0e825 commit 73a8631

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

build.gradle.kts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ kotlin {
5050
}
5151

5252
val generateBuildConfig by tasks.registering {
53-
val outputDir = layout.buildDirectory.dir("generated/source/buildConfig/com/ctrlhub")
53+
val outputDir = layout.buildDirectory.dir("generated/source/buildConfig")
5454
val packageName = "com.ctrlhub"
55+
val versionName = providers.exec {
56+
commandLine("git", "describe", "--tags", "--abbrev=0")
57+
}.standardOutput.asText.map { it.trim() }.orElse("0.0.0")
5558

5659
outputs.dir(outputDir)
5760

@@ -64,7 +67,7 @@ val generateBuildConfig by tasks.registering {
6467
package $packageName
6568
6669
object BuildConfig {
67-
const val VERSION_NAME = "$version"
70+
const val VERSION_NAME = "$versionName"
6871
}
6972
""".trimIndent()
7073
)
@@ -109,11 +112,11 @@ publishing {
109112
}
110113
}
111114

112-
//tasks.test {
113-
// useJUnitPlatform()
114-
//}
115-
116115
tasks.matching { it.name.startsWith("compileKotlin") }
117116
.configureEach {
118117
dependsOn(generateBuildConfig)
119-
}
118+
}
119+
120+
tasks.named("jvmSourcesJar") {
121+
dependsOn(generateBuildConfig)
122+
}

0 commit comments

Comments
 (0)