Skip to content

Commit 30b6f9a

Browse files
authored
Build: always read the version from a single place (#6599)
1 parent 75cc280 commit 30b6f9a

File tree

4 files changed

+9
-21
lines changed

4 files changed

+9
-21
lines changed

.github/workflows/preview.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ jobs:
2727
- run: |
2828
git clone --depth 1 --single-branch --branch ${{ inputs.branch }} https://github.com/$GITHUB_REPOSITORY
2929
cd apollo-kotlin
30-
sed -i .old 's/VERSION_NAME=\([\.0-9]*\).*/VERSION_NAME=\1-${{ inputs.prerelease }}/g' gradle.properties
31-
./gradlew librarianPublishToGcs
30+
LIBRARIAN_NIGHTLY ./gradlew librarianPublishToGcs
3231
env:
3332
LIBRARIAN_GOOGLE_SERVICES_JSON: ${{ secrets.APOLLO_KOTLIN_GOOGLE_SERVICES_JSON }}

build-logic/src/main/kotlin/Publishing.kt

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ fun Project.configureDokkaAggregate() {
151151

152152
dokka.pluginsConfiguration.getByName("versioning") {
153153
this as DokkaVersioningPluginParameters
154-
val currentVersion = findProperty("VERSION_NAME") as String
154+
val currentVersion = version()
155155
version.set(currentVersion)
156156
olderVersionsDir.fileProvider(downloadKDocVersions.map { it.outputs.files.singleFile })
157157
}
@@ -187,15 +187,6 @@ private fun Project.configureModulePublishingInternal() {
187187
}
188188
}
189189

190-
tasks.withType(Jar::class.java) {
191-
manifest {
192-
attributes["Built-By"] = findProperty("POM_DEVELOPER_ID") as String?
193-
attributes["Created-By"] = "Gradle ${gradle.gradleVersion}"
194-
attributes["Implementation-Title"] = findProperty("POM_NAME") as String?
195-
attributes["Implementation-Version"] = findProperty("VERSION_NAME") as String?
196-
}
197-
}
198-
199190
extensions.configure(PublishingExtension::class.java) {
200191
publications {
201192
when {
@@ -342,12 +333,7 @@ private fun Project.configureModulePublishingInternal() {
342333
*/
343334
private fun Project.setDefaultPomFields(mavenPublication: MavenPublication) {
344335
mavenPublication.groupId = findProperty("GROUP") as String?
345-
var version = (findProperty("VERSION_NAME") as String?) ?: error("cannot find property 'VERSION_NAME'")
346-
if (System.getenv("LIBRARIAN_RELEASE") == "true") {
347-
// This is a release, drop the -SNAPSHOT
348-
version = version.replace("-SNAPSHOT", "")
349-
}
350-
mavenPublication.version = version
336+
mavenPublication.version = version()
351337

352338
mavenPublication.pom {
353339
name.set(findProperty("POM_NAME") as String?)

build-logic/src/main/kotlin/api.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ class KotlinCompilerOptions(
2020
val version: KotlinVersion = KotlinVersion.KOTLIN_2_0,
2121
)
2222

23+
fun Project.version(): String {
24+
return Librarian.version(property("VERSION_NAME")!!.toString())
25+
}
26+
2327
fun Project.apolloLibrary(
2428
namespace: String,
2529
jvmTarget: Int? = null,
@@ -33,7 +37,7 @@ fun Project.apolloLibrary(
3337
kotlinCompilerOptions: KotlinCompilerOptions = KotlinCompilerOptions(),
3438
) {
3539
group = property("GROUP")!!
36-
version = property("VERSION_NAME")!!
40+
version = version()
3741

3842
if (androidOptions != null) {
3943
configureAndroid(namespace, androidOptions)

gradle/libraries.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ androidx-test-runner = "androidx.test:runner:1.6.2"
187187
truth = { group = "com.google.truth", name = "truth", version.ref = "truth" }
188188
turbine = { group = "app.cash.turbine", name = "turbine", version = "1.1.0" }
189189
uuid = { group = "com.benasher44", name = "uuid", version = "0.8.2" }
190-
librarian = "com.gradleup.librarian:librarian-gradle-plugin:0.0.8-SNAPSHOT-30f5819e9747430b54e96ebb8d680e0fbe30f563"
191-
nmcp = "com.gradleup.nmcp:nmcp:0.2.2-SNAPSHOT-7db79adb17a2c6ae61fc00c89f6a6518ff458ed7"
190+
librarian = "com.gradleup.librarian:librarian-gradle-plugin:0.0.10-SNAPSHOT-ffba1a28eef796c5c91a33f609761618b0ef2e5e"
192191
slf4j-simple = "org.slf4j:slf4j-simple:2.0.13"
193192
slf4j-nop = "org.slf4j:slf4j-nop:2.0.13"
194193
licensee = "app.cash.licensee:licensee-gradle-plugin:1.12.0"

0 commit comments

Comments
 (0)