Skip to content

Commit b4a2197

Browse files
authored
Exclude protolite well known types from version bump. (#6909)
Per [b/413403910](https://b.corp.google.com/issues/413403910), This adds filtering logic to not bump the version of `protolite-well-known-types` when it releases. This solves the issue of the `version` and `latestReleasedVersion` not aligning (which must be enforced due to [b/285892320](https://buganizer.corp.google.com/issues/285892320)). More specifically, this PR adds a toggle for the default `bump` behavior in `VersionBumpTask`. We then set this to `false` when the project's `artifactId` is `protolite-well-known-types`. This allows us to still [automatically] update the `latestReleasedVersion` (should we ever release well known types again), without bumping the `version`. The `VersionBumpTask` docs have been updated to accommodate this.
1 parent 12127e6 commit b4a2197

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

plugins/src/main/java/com/google/firebase/gradle/plugins/PostReleasePlugin.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ class PostReleasePlugin : Plugin<Project> {
6363
* @see VersionBumpTask
6464
*/
6565
fun registerVersionBumpTask(project: Project) =
66-
project.tasks.register<VersionBumpTask>("versionBump")
66+
project.tasks.register<VersionBumpTask>("versionBump") {
67+
// TODO(b/285892320): Remove condition when bug fixed
68+
bumpVersion.set(project.firebaseLibrary.artifactId.map {
69+
it !== "protolite-well-known-types"
70+
})
71+
}
6772

6873
/**
6974
* Registers the `moveUnreleasedChanges` task for the provided [Project].

plugins/src/main/java/com/google/firebase/gradle/plugins/VersionBumpTask.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ import org.gradle.kotlin.dsl.provideDelegate
3939
* @property releasedVersion A [ModuleVersion] of what to bump from. Defaults to the project
4040
* version.
4141
* @property newVersion A [ModuleVersion] of what to set the version to. Defaults to one patch
42-
* higher than [releasedVersion]
42+
* higher than [releasedVersion].
43+
* @property bumpVersion If set, then the default provided by [newVersion] will be bumped by one patch. Defaults to `true`.
4344
* @see PostReleasePlugin
4445
*/
4546
abstract class VersionBumpTask : DefaultTask() {
@@ -52,16 +53,22 @@ abstract class VersionBumpTask : DefaultTask() {
5253
@get:[Optional Input]
5354
abstract val newVersion: Property<ModuleVersion>
5455

56+
@get:[Optional Input]
57+
abstract val bumpVersion: Property<Boolean>
58+
5559
init {
5660
configure()
5761
}
5862

5963
@TaskAction
6064
fun build() {
65+
val latestVersion = releasedVersion.get()
66+
val version = newVersion.orNull ?: if(bumpVersion.get()) latestVersion.bump() else latestVersion
67+
6168
versionFile.get().asFile.rewriteLines {
6269
when {
63-
it.startsWith("version=") -> "version=${newVersion.get()}"
64-
it.startsWith("latestReleasedVersion") -> "latestReleasedVersion=${releasedVersion.get()}"
70+
it.startsWith("version=") -> "version=${version}"
71+
it.startsWith("latestReleasedVersion") -> "latestReleasedVersion=${latestVersion}"
6572
else -> it
6673
}
6774
}
@@ -70,7 +77,7 @@ abstract class VersionBumpTask : DefaultTask() {
7077
fun configure() {
7178
versionFile.convention(project.layout.projectDirectory.file("gradle.properties"))
7279
releasedVersion.convention(computeReleasedVersion())
73-
newVersion.convention(releasedVersion.map { it.bump() })
80+
bumpVersion.convention(true)
7481
}
7582

7683
fun computeReleasedVersion(): ModuleVersion? {

0 commit comments

Comments
 (0)