Skip to content

App Versioning 2.0 - #46

Merged
ychescale9 merged 11 commits into
mainfrom
yc/v2
Oct 25, 2026
Merged

ychescale9 merged 11 commits into
mainfrom
yc/v2

Conversation

@ychescale9

Copy link
Copy Markdown
Member

New version mainly improves the version code / name configuration APIs and provides some new APIs to support SemVer-based version code customization.

appVersioning {
    versionCode.set {
        val offset = 1_800_000_000
        tag.toSemVer(prefix = "android-").toVersionCode() + offset
    }
    versionName.set {
        val suffix = if (variant.isDebugBuild) " (${variant.variantName})" else ""
        "${tag.name} (${tag.commitHash})$suffix"
    }
}

tag: GitTag and variant: VariantInfo are now part of the lambda's receiver type (VersionContext).

providers: ProviderFactory is no longer passed into the lambda as calls such as providers.environmentVariable("BUILD_NUMBER") are never seen by Gradle when fingerprinting the task inputs, so the task might be incorrectly marked as UP-TO-DATE or FROM-CACHE even when the task should be executed due to changes to external values sourced from the providers.

Instead use Gradle's Provider chaining APIs to lazily map the external values provider to the VersionCodeSpec or VersionNameSpec property:

import io.github.reactivecircus.appversioning.VersionCodeSpec

val buildNumber = providers.environmentVariable("BUILD_NUMBER").orElse("0")

appVersioning {
    versionCode.set(
        buildNumber.map { buildNum ->
            VersionCodeSpec {
                tag.toSemVer().toVersionCode() + buildNum
            }
        }
    )
}

See the migration guide for the full changes.

- New `versionCode` and and `versionName` APIs based on `fun interface` and `VersionContext` receiver.
- Remove `ProviderFactory` from lambda param.
- `SemVer` - new `parse`, `parseOrNull`, `toVersionCode(digitsPerComponent)` APIs.
- `GitTag` - new `toSemVer(prefix)` API.
- Move data classes to regular classes in public APIs.
…d and functional tests, clean up public APIs.
@ychescale9
ychescale9 merged commit 4857512 into main Oct 25, 2026
10 checks passed
@ychescale9
ychescale9 deleted the yc/v2 branch October 25, 2026 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant