Skip to content

Commit

Permalink
Read version.properties file during build
Browse files Browse the repository at this point in the history
janseeger committed Dec 19, 2023
1 parent 3d692e6 commit 4cc7449
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import java.util.Properties

plugins {
alias(libs.plugins.androidLibrary)
alias(libs.plugins.jetbrainsKotlinAndroid)
@@ -39,11 +41,28 @@ tasks.withType<Test>().configureEach {
outputs.upToDateWhen { false }
}

fun Project.setupVersionInfo(): Properties {
val versionProperties = File(project.rootDir, "version.properties")
return versionProperties.inputStream().use { inputStream ->
Properties().apply {
load(inputStream)
project.version = getVersionName()
}
}
}

fun Properties.getVersionName(): String {
val major = (get("majorVersion") as String).toInt()
val minor = (get("minorVersion") as String).toInt()
val patch = (get("patchVersion") as String).toInt()
return "$major.$minor.$patch"
}

publishing {
publications.withType<MavenPublication> {
groupId = "de.sipgate"
artifactId = project.name
version = project.version.toString()
artifactId = "federmappe"
version = setupVersionInfo().getVersionName()

pom {
name.set("Federmappe")

0 comments on commit 4cc7449

Please sign in to comment.