Skip to content

Commit cda7853

Browse files
committed
Share version computation between lib and Android sample
1 parent d565d6b commit cda7853

File tree

3 files changed

+40
-19
lines changed

3 files changed

+40
-19
lines changed

build.gradle.kts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,20 @@ plugins {
77
alias(libs.plugins.compose.multiplatform) apply false
88
alias(libs.plugins.jetbrains.kotlin.jvm) apply false
99
}
10+
11+
version =
12+
runCatching {
13+
// Try to get the latest annotated or lightweight tag name
14+
"git describe --tags --abbrev=0".runCommand().trim()
15+
}
16+
.getOrElse {
17+
"0.0.0-SNAPSHOT" // fallback if no tags yet
18+
}
19+
20+
private fun String.runCommand(): String =
21+
ProcessBuilder(*split(" ").toTypedArray())
22+
.redirectErrorStream(true)
23+
.start()
24+
.inputStream
25+
.bufferedReader()
26+
.readText()

lib/build.gradle.kts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,26 +78,13 @@ android {
7878
buildFeatures { compose = true }
7979
}
8080

81-
version =
82-
runCatching {
83-
// Try to get the latest annotated or lightweight tag name
84-
"git describe --tags --abbrev=0".runCommand().trim()
85-
}
86-
.getOrElse {
87-
"0.0.0-SNAPSHOT" // fallback if no tags yet
88-
}
89-
90-
private fun String.runCommand(): String =
91-
ProcessBuilder(*split(" ").toTypedArray())
92-
.redirectErrorStream(true)
93-
.start()
94-
.inputStream
95-
.bufferedReader()
96-
.readText()
97-
9881
mavenPublishing {
9982
// Define coordinates for the published artifact
100-
coordinates(groupId = "io.github.pingpongboss", artifactId = "compose-exploded-layers")
83+
coordinates(
84+
groupId = "io.github.pingpongboss",
85+
artifactId = "compose-exploded-layers",
86+
version = rootProject.version.toString(),
87+
)
10188

10289
// Configure POM metadata for the published artifact
10390
pom {

samples/android/build.gradle.kts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@ plugins {
66
alias(libs.plugins.kotlin.compose)
77
}
88

9+
version =
10+
runCatching {
11+
// Try to get the latest annotated or lightweight tag name
12+
"git describe --tags --abbrev=0".runCommand().trim()
13+
}
14+
.getOrElse {
15+
"0.0.0-SNAPSHOT" // fallback if no tags yet
16+
}
17+
18+
private fun String.runCommand(): String =
19+
ProcessBuilder(*split(" ").toTypedArray())
20+
.redirectErrorStream(true)
21+
.start()
22+
.inputStream
23+
.bufferedReader()
24+
.readText()
25+
926
android {
1027
namespace = "io.github.pingpongboss.explodedlayers.samples.android"
1128
compileSdk = 36
@@ -14,7 +31,7 @@ android {
1431
minSdk = 36
1532
targetSdk = 36
1633
versionCode = 1
17-
versionName = "1.0"
34+
versionName = rootProject.version.toString()
1835

1936
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2037
}

0 commit comments

Comments
 (0)