Skip to content

Commit dc23d92

Browse files
committed
Add support for opting out of bump
1 parent b0d8622 commit dc23d92

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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)