### Configure Bare Git Repository Support Source: https://context7.com/reactivecircus/app-versioning/llms.txt Configure the plugin to function correctly with bare Git repositories, where the .git directory is a symbolic link. Example points to the bare repository location. ```kotlin appVersioning { // Point to the bare repository location bareGitRepoDirectory.set(rootProject.file("../.repo/projects/app.git")) } ``` -------------------------------- ### Default Version Code Generation Source: https://context7.com/reactivecircus/app-versioning/llms.txt Example of the default behavior using SemVer tags. ```kotlin // With git tag "1.3.1": // versionCode = 1 * 10000 + 3 * 100 + 1 = 10301 // versionName = "1.3.1" // Run the generate task // ./gradlew generateAppVersionInfoForRelease // Output: // Generated app version code: 10301. // Generated app version name: "1.3.1". ``` -------------------------------- ### Specify Custom Git Root Directory Source: https://context7.com/reactivecircus/app-versioning/llms.txt Define a custom directory for the Git repository root when it differs from the root Gradle project directory. Example sets Git root one level above the Gradle project. ```kotlin appVersioning { // Git root is one level above the Gradle project gitRootDirectory.set(rootProject.file("../")) } ``` -------------------------------- ### Parse Git Tags to SemVer Objects Source: https://context7.com/reactivecircus/app-versioning/llms.txt Use the `toSemVer()` extension function to parse Git tags into type-safe SemVer objects, providing access to major, minor, patch, pre-release, and build metadata. Example calculates version code based on SemVer components. ```kotlin import io.github.reactivecircus.appversioning.toSemVer appVersioning { overrideVersionCode { gitTag, _, _ -> val semVer = gitTag.toSemVer() // semVer.major: Int // semVer.minor: Int // semVer.patch: Int // semVer.preRelease: String? (e.g., "rc01", "alpha04") // semVer.buildMetadata: String? (e.g., "app-b") // Supports "v" prefix: "v1.2.3" -> major=1, minor=2, patch=3 semVer.major * 10000 + semVer.minor * 100 + semVer.patch } } ``` -------------------------------- ### Filter Git Tags with Glob Patterns Source: https://context7.com/reactivecircus/app-versioning/llms.txt Use glob patterns to filter Git tags, useful when tags are for multiple apps or include build metadata. Example selects tags ending with '+app-b'. ```kotlin appVersioning { // Only use tags matching the pattern for app-b // e.g., "2.29.0-rc01+app-b", "1.5.8+app-b" tagFilter.set("[0-9]*.[0-9]*.[0-9]*+app-b") } // Tags: "1.5.8+app-a", "2.29.0-rc01+app-b", "10.87.9-alpha04+app-c" // Selected tag: "2.29.0-rc01+app-b" ``` -------------------------------- ### Customize Version Name with GitTag Data Source: https://context7.com/reactivecircus/app-versioning/llms.txt Override the version name using the `GitTag` data class, which provides raw tag name, commits since tag, and commit hash. Example appends commit count and hash if commits exist. ```kotlin // GitTag properties available in customizers: appVersioning { overrideVersionName { gitTag, _, _ -> // gitTag.rawTagName: "1.5.0" (the tag name) // gitTag.commitsSinceLatestTag: 3 (commits since tag) // gitTag.commitHash: "abc1234" (short commit hash) if (gitTag.commitsSinceLatestTag > 0) { "${gitTag.rawTagName}+${gitTag.commitsSinceLatestTag}.${gitTag.commitHash}" } else { gitTag.rawTagName } } } // Tag "1.5.0" with 3 commits since: "1.5.0+3.abc1234" // Tag "1.5.0" with 0 commits since: "1.5.0" ``` -------------------------------- ### Publish and Release to Maven Central Source: https://github.com/reactivecircus/app-versioning/blob/main/RELEASING.md Execute the Gradle task to publish the plugin to Maven Central. ```bash ./gradlew publishAndReleaseToMavenCentral ``` -------------------------------- ### Groovy DSL for Version Customization Source: https://context7.com/reactivecircus/app-versioning/llms.txt Demonstrates Groovy DSL usage for customizing version code and name. Includes importing `SemVer` and accessing environment variables for build numbers. ```groovy // build.gradle (Groovy) import io.github.reactivecircus.appversioning.SemVer appVersioning { overrideVersionCode { gitTag, providers, variantInfo -> def semVer = SemVer.fromGitTag(gitTag) semVer.major * 10000 + semVer.minor * 100 + semVer.patch } overrideVersionName { gitTag, providers, variantInfo -> def buildNumber = providers .environmentVariable("BUILD_NUMBER") .getOrElse("0") as Integer "${gitTag.rawTagName} - #$buildNumber (${gitTag.commitHash})".toString() } } ``` -------------------------------- ### Bare Git Repository Support Source: https://context7.com/reactivecircus/app-versioning/llms.txt Configure the plugin to work with bare Git repositories, which are typically used on servers and where the `.git` directory is a symbolic link. ```APIDOC ## Bare Git Repository Support Configure the plugin to work with bare Git repositories where .git is a symbolic link. ### Method Configuration (DSL) ### Endpoint N/A ### Parameters #### Request Body - **bareGitRepoDirectory** (File) - Optional - Path to the bare Git repository directory. ### Request Example ```kotlin appVersioning { // Point to the bare repository location bareGitRepoDirectory.set(rootProject.file("../.repo/projects/app.git")) } ``` ### Response N/A #### Response Example N/A ``` -------------------------------- ### Configure Plugin Repositories Source: https://github.com/reactivecircus/app-versioning/blob/main/README.md Add Maven Central to your plugin management or buildscript repositories to enable plugin resolution. ```kotlin // in settings.gradle.kts pluginManagement { repositories { mavenCentral() } } ``` ```kotlin // in root build.gradle.kts buildscript { repositories { mavenCentral() } } ``` -------------------------------- ### Retrieve Generated Version Code and Name Source: https://github.com/reactivecircus/app-versioning/blob/main/README.md Access the generated versionCode and versionName files from the build output directory. These files contain the version information used for the build. ```bash VERSION_CODE=$(cat app/build/outputs/app_versioning//version_code.txt) VERSION_NAME=$(cat app/build/outputs/app_versioning//version_name.txt) ``` -------------------------------- ### Apply App Versioning Plugin Source: https://context7.com/reactivecircus/app-versioning/llms.txt Configure the plugin in settings and build files to enable automatic versioning. ```kotlin // settings.gradle.kts pluginManagement { repositories { mavenCentral() } } // app/build.gradle.kts plugins { id("com.android.application") id("io.github.reactivecircus.app-versioning") version "1.6.0" } ``` -------------------------------- ### Configure Bare Git Repository Directory Source: https://github.com/reactivecircus/app-versioning/blob/main/README.md Specify the directory of a bare Git repository when the .git directory is a symbolic link. This overrides the gitRootDirectory property. ```kotlin appVersioning { /** * Bare Git repository directory. * Use this to explicitly set the directory of a bare git repository (e.g. `app.git`) instead of the standard `.git`. * Setting this will override the value of [gitRootDirectory] property. */ bareGitRepoDirectory.set(rootProject.file("../.repo/projects/app.git")) // if the .git directory in the Gradle project root is a symlink to app.git. } ``` -------------------------------- ### Tag Release Version Source: https://github.com/reactivecircus/app-versioning/blob/main/RELEASING.md Create an annotated Git tag for the released version. Replace X.Y.Z with the actual version number. ```bash git tag -a X.Y.X -m "X.Y.Z" ``` -------------------------------- ### Print App Version Info Task Source: https://context7.com/reactivecircus/app-versioning/llms.txt Run this Gradle task to display the current generated version code and name without rebuilding the project. It shows the project, build variant, versionCode, and versionName. ```bash ./gradlew printAppVersionInfoForRelease # Output: # App version info generated by Android App Versioning plugin: # Project: ":app" # Build variant: release # versionCode: 10301 # versionName: "1.3.1" ``` -------------------------------- ### Apply the Plugin Source: https://github.com/reactivecircus/app-versioning/blob/main/README.md Apply the plugin to your Android application module using the plugins block. ```kotlin plugins { id("com.android.application") id("io.github.reactivecircus.app-versioning") version "x.y.z" } ``` ```groovy plugins { id 'com.android.application' id 'io.github.reactivecircus.app-versioning' version "x.y.z" } ``` -------------------------------- ### Fetch tags from remote Source: https://github.com/reactivecircus/app-versioning/blob/main/README.md Enable automatic fetching of Git tags from remote if none are found locally. ```kt appVersioning { /** * Whether to fetch git tags from remote when no git tag can be found locally. * * Default is `false`. */ fetchTagsWhenNoneExistsLocally.set(true) } ``` -------------------------------- ### GitHub Actions CI/CD Integration Source: https://context7.com/reactivecircus/app-versioning/llms.txt Configure GitHub Actions to fetch tags and access generated version information from output files. Ensure `fetch-depth: 0` is set for `actions/checkout` to retrieve all Git tags. ```yaml # .github/workflows/release.yml - uses: actions/checkout@v5 with: fetch-depth: 0 # Required for git tags - name: Build Release run: ./gradlew assembleRelease - name: Get Version Info run: | VERSION_CODE=$(cat app/build/outputs/app_versioning/release/version_code.txt) VERSION_NAME=$(cat app/build/outputs/app_versioning/release/version_name.txt) echo "Version Code: $VERSION_CODE" echo "Version Name: $VERSION_NAME" ``` -------------------------------- ### SemVer Parsing with toSemVer Source: https://context7.com/reactivecircus/app-versioning/llms.txt The `toSemVer()` extension function parses Git tags into type-safe SemVer objects, breaking them down into major, minor, patch, pre-release, and build metadata components. ```APIDOC ## SemVer Parsing with toSemVer The `toSemVer()` extension function parses Git tags into type-safe SemVer objects with major, minor, patch, pre-release, and build metadata components. ### Method Extension Function (Kotlin) ### Endpoint N/A ### Parameters #### Input - **gitTag** (GitTag) - The Git tag object to parse. #### SemVer Object Properties - **major** (Int) - **minor** (Int) - **patch** (Int) - **preRelease** (String?) - e.g., "rc01", "alpha04" - **buildMetadata** (String?) - e.g., "app-b" ### Request Example ```kotlin import io.github.reactivecircus.appversioning.toSemVer appVersioning { overrideVersionCode { gitTag, _, _ -> val semVer = gitTag.toSemVer() // semVer.major: Int // semVer.minor: Int // semVer.patch: Int // semVer.preRelease: String? (e.g., "rc01", "alpha04") // semVer.buildMetadata: String? (e.g., "app-b") // Supports "v" prefix: "v1.2.3" -> major=1, minor=2, patch=3 semVer.major * 10000 + semVer.minor * 100 + semVer.patch } } ``` ### Response N/A #### Response Example N/A ``` -------------------------------- ### Access Version Output Files in Shell Scripts Source: https://context7.com/reactivecircus/app-versioning/llms.txt The plugin writes generated version information to `version_code.txt` and `version_name.txt` files in the build output directory. These files can be read in shell scripts for use in subsequent CI steps, such as uploading to the Play Store or Bugsnag. ```bash # Output file locations: # app/build/outputs/app_versioning//version_code.txt # app/build/outputs/app_versioning//version_name.txt # Read version info in shell scripts: VERSION_CODE=$(cat app/build/outputs/app_versioning/release/version_code.txt) VERSION_NAME=$(cat app/build/outputs/app_versioning/release/version_name.txt) # Use in subsequent CI steps (e.g., upload to Play Store, Bugsnag): curl -X POST "https://api.example.com/upload" \ -d "version_code=$VERSION_CODE" \ -d "version_name=$VERSION_NAME" ``` -------------------------------- ### Apache License Source: https://github.com/reactivecircus/app-versioning/blob/main/README.md Standard Apache 2.0 license text. ```text Copyright 2020 Yang Chen Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ``` -------------------------------- ### Push Changes and Tags Source: https://github.com/reactivecircus/app-versioning/blob/main/RELEASING.md Push local commits and tags to the remote repository. ```bash git push && git push --tags ``` -------------------------------- ### Variant-Based Version Customization Source: https://context7.com/reactivecircus/app-versioning/llms.txt Customize versioning logic based on specific build variants. ```kotlin import io.github.reactivecircus.appversioning.toSemVer appVersioning { overrideVersionCode { gitTag, _, variantInfo -> // Add offset for paid flavor to ensure higher version code val offset = if (variantInfo.flavorName == "paid") 1 else 0 val semVer = gitTag.toSemVer() semVer.major * 10000 + semVer.minor * 100 + semVer.patch + offset } overrideVersionName { gitTag, _, variantInfo -> // Append variant name suffix for debug builds val suffix = if (variantInfo.isDebugBuild) " (${variantInfo.variantName})" else "" gitTag.toString() + suffix } } // For "paidDebug" variant with tag "1.0.0": // versionCode = 10001, versionName = "1.0.0 (paidDebug)" // For "freeRelease" variant with tag "1.0.0": // versionCode = 10000, versionName = "1.0.0" ``` -------------------------------- ### Groovy DSL Support Source: https://context7.com/reactivecircus/app-versioning/llms.txt The plugin supports Groovy closures for version customization within Groovy build scripts, providing equivalent functionality to Kotlin DSL. ```APIDOC ## Groovy DSL Support The plugin supports Groovy closures for version customization in Groovy build scripts. ### Method Configuration (Groovy DSL) ### Endpoint N/A ### Parameters N/A ### Request Example ```groovy // build.gradle (Groovy) import io.github.reactivecircus.appversioning.SemVer appVersioning { overrideVersionCode { gitTag, providers, variantInfo -> def semVer = SemVer.fromGitTag(gitTag) semVer.major * 10000 + semVer.minor * 100 + semVer.patch } overrideVersionName { gitTag, providers, variantInfo -> def buildNumber = providers .environmentVariable("BUILD_NUMBER") .getOrElse("0") as Integer "${gitTag.rawTagName} - #$buildNumber (${gitTag.commitHash})".toString() } } ``` ### Response N/A #### Response Example N/A ``` -------------------------------- ### Enable Release Build Only Mode Source: https://context7.com/reactivecircus/app-versioning/llms.txt Configure the plugin to generate version information exclusively for release build types, omitting debug builds. Lists available versioning tasks when enabled. ```kotlin appVersioning { releaseBuildOnly.set(true) } // Available tasks (debug tasks excluded): // ./gradlew tasks --group=versioning // generateAppVersionInfoForRelease // printAppVersionInfoForRelease ``` -------------------------------- ### Fetch Tags from Remote When None Exist Locally Source: https://context7.com/reactivecircus/app-versioning/llms.txt Enable automatic fetching of Git tags from the remote repository if no local tags are found. This is particularly useful in CI environments with shallow clones. ```kotlin appVersioning { fetchTagsWhenNoneExistsLocally.set(true) } // If no local tags found: // "No git tags found. Fetching tags from remote." ``` -------------------------------- ### Environment Variables in Version Generation Source: https://context7.com/reactivecircus/app-versioning/llms.txt Access CI/CD environment variables during version generation using ProviderFactory. ```kotlin import io.github.reactivecircus.appversioning.toSemVer appVersioning { overrideVersionCode { gitTag, providers, _ -> val buildNumber = providers .environmentVariable("BUILD_NUMBER") .getOrElse("0").toInt() val semVer = gitTag.toSemVer() semVer.major * 10000 + semVer.minor * 100 + semVer.patch + buildNumber } } // With git tag "1.2.0" and BUILD_NUMBER=5: // versionCode = 1 * 10000 + 2 * 100 + 0 + 5 = 10205 ``` -------------------------------- ### Set custom Git root directory Source: https://github.com/reactivecircus/app-versioning/blob/main/README.md Specify a custom directory if the .git folder is not in the root Gradle project. ```kt appVersioning { /** * Git root directory used for fetching git tags. * Use this to explicitly set the git root directory when the root Gradle project is not the git root directory. */ gitRootDirectory.set(rootProject.file("../")) // if the .git directory is in the root Gradle project's parent directory. } ``` -------------------------------- ### Fetching Tags from Remote Source: https://context7.com/reactivecircus/app-versioning/llms.txt Enable automatic tag fetching from the remote repository when no local tags are found. This is particularly useful in CI environments with shallow Git clones. ```APIDOC ## Fetching Tags from Remote Enable automatic tag fetching from remote when no local tags exist, useful for CI environments with shallow clones. ### Method Configuration (DSL) ### Endpoint N/A ### Parameters #### Request Body - **fetchTagsWhenNoneExistsLocally** (Boolean) - Optional - If true, the plugin will attempt to fetch tags from the remote if none are found locally. Default is false. ### Request Example ```kotlin appVersioning { fetchTagsWhenNoneExistsLocally.set(true) } ``` ### Response N/A #### Response Example N/A ``` -------------------------------- ### Custom Version Name with overrideVersionName Source: https://context7.com/reactivecircus/app-versioning/llms.txt Customize version name strings using git tag metadata and environment variables. ```kotlin appVersioning { overrideVersionName { gitTag, providers, variantInfo -> val buildNumber = providers .environmentVariable("BUILD_NUMBER") .getOrElse("0").toInt() "${gitTag.rawTagName} - #$buildNumber (${gitTag.commitHash})" } } // With git tag "1.5.0", BUILD_NUMBER=42, commit hash "abc1234": // versionName = "1.5.0 - #42 (abc1234)" ``` -------------------------------- ### Define Custom Versioning Rules Source: https://github.com/reactivecircus/app-versioning/blob/main/README.md Implement custom lambdas to override the default versionCode and versionName generation logic. ```kotlin appVersioning { overrideVersionCode { gitTag, providers, variantInfo -> // TODO generate an Int from the given gitTag, providers, build variant } overrideVersionName { gitTag, providers, variantInfo -> // TODO generate a String from the given gitTag, providers, build variant } } ``` -------------------------------- ### Override Version Code with Environment Variable Source: https://github.com/reactivecircus/app-versioning/blob/main/README.md Integrates a CI-provided BUILD_NUMBER into the version code calculation. ```kt import io.github.reactivecircus.appversioning.toSemVer appVersioning { overrideVersionCode { gitTag, providers, _ -> val buildNumber = providers .environmentVariable("BUILD_NUMBER") .getOrElse("0").toInt() val semVer = gitTag.toSemVer() semVer.major * 10000 + semVer.minor * 100 + semVer.patch + buildNumber } } ``` ```groovy import io.github.reactivecircus.appversioning.SemVer appVersioning { overrideVersionCode { gitTag, providers, variantInfo -> def buildNumber = providers .environmentVariable("BUILD_NUMBER") .getOrElse("0") as Integer def semVer = SemVer.fromGitTag(gitTag) semVer.major * 10000 + semVer.minor * 100 + semVer.patch + buildNumber } } ``` -------------------------------- ### Commit Changes for Next Development Version Source: https://github.com/reactivecircus/app-versioning/blob/main/RELEASING.md Commit changes to prepare for the next development iteration after a release. ```bash git commit -am "Prepare next development version." ``` -------------------------------- ### Override Version Name with Environment Variable Source: https://github.com/reactivecircus/app-versioning/blob/main/README.md Customizes the version name by combining tag information and environment variables. ```kt import io.github.reactivecircus.appversioning.toSemVer appVersioning { overrideVersionName { gitTag, providers, _ -> // a custom versionName combining the tag name, commitHash and an environment variable val buildNumber = providers .environmentVariable("BUILD_NUMBER") .getOrElse("0").toInt() "${gitTag.rawTagName} - #$buildNumber (${gitTag.commitHash})" } } ``` ```groovy appVersioning { overrideVersionName { gitTag, providers, variantInfo -> // a custom versionName combining the tag name, commitHash and an environment variable def buildNumber = providers .environmentVariable("BUILD_NUMBER") .getOrElse("0") as Integer "${gitTag.rawTagName} - #$buildNumber (${gitTag.commitHash})".toString() } } ``` -------------------------------- ### Fetch Git Tags in GitHub Actions Source: https://github.com/reactivecircus/app-versioning/blob/main/README.md Configure GitHub Actions to fetch all Git history, including tags, which is necessary for app-versioning to function correctly. Set fetch-depth to 0. ```yaml - uses: actions/checkout@v5 with: fetch-depth: 0 ``` -------------------------------- ### Timestamp-Based Version Code Source: https://context7.com/reactivecircus/app-versioning/llms.txt Generate version codes using Unix epoch timestamps. ```kotlin import java.time.Instant appVersioning { overrideVersionCode { _, _, _ -> Instant.now().epochSecond.toInt() } } // Output: // Generated app version code: 1599750437. ``` -------------------------------- ### VariantInfo Properties Source: https://context7.com/reactivecircus/app-versioning/llms.txt The `VariantInfo` class provides build variant information, allowing for variant-specific version customization based on build type, flavor, and debug/release status. ```APIDOC ## VariantInfo Properties The `VariantInfo` class provides build variant information for variant-specific version customization. ### Method Customization (DSL) ### Endpoint N/A ### Parameters #### Request Body (within `overrideVersionCode` or similar customizers) - **variantInfo** (VariantInfo) - Object containing build variant details. - **buildType** (String?) - The build type (e.g., "debug", "release"). - **flavorName** (String) - The product flavor name (empty if none). - **variantName** (String) - The full variant name (e.g., "paidRelease"). - **isDebugBuild** (Boolean) - True if the build type is "debug". - **isReleaseBuild** (Boolean) - True if the build type is "release". ### Request Example ```kotlin appVersioning { overrideVersionCode { gitTag, _, variantInfo -> // variantInfo.buildType: String? ("debug", "release", or custom) // variantInfo.flavorName: String (product flavor name, empty if none) // variantInfo.variantName: String (full variant name, e.g., "paidRelease") // variantInfo.isDebugBuild: Boolean (true if buildType == "debug") // variantInfo.isReleaseBuild: Boolean (true if buildType == "release") val base = gitTag.toSemVer().let { it.major * 10000 + it.minor * 100 + it.patch } if (variantInfo.isReleaseBuild) base else base + 1 } } ``` ### Response N/A #### Response Example N/A ``` -------------------------------- ### Commit Changes for Release Source: https://github.com/reactivecircus/app-versioning/blob/main/RELEASING.md Commit staged changes to prepare for a release. Replace X.Y.Z with the actual version number. ```bash git commit -am "Prepare for release X.Y.Z." ``` -------------------------------- ### Disable the plugin Source: https://github.com/reactivecircus/app-versioning/blob/main/README.md Set enabled to false to revert to standard defaultConfig versioning. ```kt appVersioning { /** * Whether to enable the plugin. * * Default is `true`. */ enabled.set(false) } ``` -------------------------------- ### Customize versioning by build variant Source: https://github.com/reactivecircus/app-versioning/blob/main/README.md Use variantInfo to conditionally override versionCode and versionName based on product flavors or build types. ```kt import io.github.reactivecircus.appversioning.toSemVer appVersioning { overrideVersionCode { gitTag, _, _ -> // add 1 to the versionCode for builds with the "paid" product flavor val offset = if (variantInfo.flavorName == "paid") 1 else 0 val semVer = gitTag.toSemVer() semVer.major * 10000 + semVer.minor * 100 + semVer.patch + offset } overrideVersionName { gitTag, _, variantInfo -> // append build variant to the versionName for debug builds val suffix = if (variantInfo.isDebugBuild) " (${variantInfo.variantName})" else "" gitTag.toString() + suffix } } ``` ```groovy import io.github.reactivecircus.appversioning.SemVer appVersioning { overrideVersionCode { gitTag, providers, variantInfo -> // add 1 to the versionCode for builds with the "paid" product flavor def offset if (variantInfo.flavorName == "paid") { offset = 1 } else { offset = 0 } def semVer = SemVer.fromGitTag(gitTag) semVer.major * 10000 + semVer.minor * 100 + semVer.patch + offset } overrideVersionName { gitTag, providers, variantInfo -> // append build variant to the versionName for debug builds def suffix if (variantInfo.debugBuild == true) { suffix = " (" + variantInfo.variantName + ")" } else { suffix = "" } gitTag.toString() + suffix } } ``` -------------------------------- ### Custom Version Code with overrideVersionCode Source: https://context7.com/reactivecircus/app-versioning/llms.txt Implement custom logic for version code generation using the overrideVersionCode lambda. ```kotlin import io.github.reactivecircus.appversioning.toSemVer appVersioning { // Allocate 3 digits per component (supports versions up to 999.999.999) overrideVersionCode { gitTag, _, _ -> val semVer = gitTag.toSemVer() semVer.major * 1000000 + semVer.minor * 1000 + semVer.patch } } // With git tag "2.15.3": // versionCode = 2 * 1000000 + 15 * 1000 + 3 = 2015003 ``` -------------------------------- ### Custom Git Root Directory Source: https://context7.com/reactivecircus/app-versioning/llms.txt Specify a custom directory for the Git root when the project's root Gradle directory differs from the Git repository's root. ```APIDOC ## Custom Git Root Directory Specify the git root directory when the root Gradle project differs from the git repository root. ### Method Configuration (DSL) ### Endpoint N/A ### Parameters #### Request Body - **gitRootDirectory** (File) - Optional - Path to the Git repository root directory. ### Request Example ```kotlin appVersioning { // Git root is one level above the Gradle project gitRootDirectory.set(rootProject.file("../")) } ``` ### Response N/A #### Response Example N/A ``` -------------------------------- ### Release Build Only Mode Source: https://context7.com/reactivecircus/app-versioning/llms.txt Configure the plugin to generate version information exclusively for release build types, skipping debug builds. ```APIDOC ## Release Build Only Mode Configure the plugin to generate version information only for release build types, skipping debug builds. ### Method Configuration (DSL) ### Endpoint N/A ### Parameters #### Request Body - **releaseBuildOnly** (Boolean) - Optional - If true, only release builds will generate version information. Default is false. ### Request Example ```kotlin appVersioning { releaseBuildOnly.set(true) } ``` ### Response N/A #### Response Example N/A ``` -------------------------------- ### Restrict to release builds Source: https://github.com/reactivecircus/app-versioning/blob/main/README.md Limit version generation to release build types only. ```kt appVersioning { /** * Whether to only generate version name and version code for `release` builds. * * Default is `false`. */ releaseBuildOnly.set(true) } ``` -------------------------------- ### Override Version Code with Timestamp Source: https://github.com/reactivecircus/app-versioning/blob/main/README.md Uses the current Unix timestamp to ensure the version code monotonically increases. ```kt import java.time.Instant appVersioning { overrideVersionCode { _, _, _ -> Instant.now().epochSecond.toInt() } } ``` ```groovy appVersioning { overrideVersionCode { gitTag, providers, variantInfo -> Instant.now().epochSecond.intValue() } } ``` -------------------------------- ### Configure tag filtering Source: https://github.com/reactivecircus/app-versioning/blob/main/README.md Restrict version generation to tags matching a specific glob pattern. ```kt appVersioning { tagFilter.set("[0-9]*.[0-9]*.[0-9]*+app-b") } ``` -------------------------------- ### Disabling the Plugin Source: https://context7.com/reactivecircus/app-versioning/llms.txt Disable the App Versioning plugin to revert to using `versionCode` and `versionName` defined in the `defaultConfig` block or manifest. ```APIDOC ## Disabling the Plugin Disable the plugin to fall back to versionCode and versionName defined in the defaultConfig block or manifest. ### Method Configuration (DSL) ### Endpoint N/A ### Parameters #### Request Body - **enabled** (Boolean) - Optional - If false, the plugin is disabled. Default is true. ### Request Example ```kotlin appVersioning { enabled.set(false) } ``` ### Response N/A #### Response Example N/A ``` -------------------------------- ### Override Version Code with SemVer Source: https://github.com/reactivecircus/app-versioning/blob/main/README.md Allocates 3 digits per SemVer component to allow version components up to 999. ```kt import io.github.reactivecircus.appversioning.toSemVer appVersioning { overrideVersionCode { gitTag, _, _ -> val semVer = gitTag.toSemVer() semVer.major * 1000000 + semVer.minor * 1000 + semVer.patch } } ``` ```groovy import io.github.reactivecircus.appversioning.SemVer appVersioning { overrideVersionCode { gitTag, providers, variantInfo -> def semVer = SemVer.fromGitTag(gitTag) semVer.major * 1000000 + semVer.minor * 1000 + semVer.patch } } ``` -------------------------------- ### Disable the App Versioning Plugin Source: https://context7.com/reactivecircus/app-versioning/llms.txt Disable the plugin to revert to using versionCode and versionName defined in the defaultConfig block or manifest. Shows output message when disabled. ```kotlin appVersioning { enabled.set(false) } // Output when building: // Android App Versioning plugin is disabled. ``` -------------------------------- ### Tag Filtering with Glob Patterns Source: https://context7.com/reactivecircus/app-versioning/llms.txt Filter Git tags using glob patterns to select specific tags for versioning, useful when a repository contains tags for multiple applications or includes build metadata. ```APIDOC ## Tag Filtering with Glob Patterns Filter Git tags using glob patterns when the repository contains tags for multiple apps or when using build metadata in tag names. ### Method Configuration (DSL) ### Endpoint N/A ### Parameters #### Request Body - **tagFilter** (String) - Optional - Glob pattern to filter Git tags. Example: `"[0-9]*.[0-9]*.[0-9]*+app-b"` ### Request Example ```kotlin appVersioning { // Only use tags matching the pattern for app-b // e.g., "2.29.0-rc01+app-b", "1.5.8+app-b" tagFilter.set("[0-9]*.[0-9]*.[0-9]*+app-b") } ``` ### Response N/A #### Response Example N/A ``` -------------------------------- ### GitTag Data Class Source: https://context7.com/reactivecircus/app-versioning/llms.txt The `GitTag` data class provides type-safe access to Git tag information, including the raw tag name, the number of commits since the tag, and the commit hash. ```APIDOC ## GitTag Data Class The `GitTag` class provides type-safe access to Git tag information including raw tag name, commits since tag, and commit hash. ### Method Customization (DSL) ### Endpoint N/A ### Parameters #### Request Body (within `overrideVersionName` or similar customizers) - **gitTag** (GitTag) - Object containing Git tag information. - **rawTagName** (String) - The name of the Git tag. - **commitsSinceLatestTag** (Int) - The number of commits made since the latest tag. - **commitHash** (String) - The short commit hash. ### Request Example ```kotlin appVersioning { overrideVersionName { gitTag, _, _ -> // gitTag.rawTagName: "1.5.0" (the tag name) // gitTag.commitsSinceLatestTag: 3 (commits since tag) // gitTag.commitHash: "abc1234" (short commit hash) if (gitTag.commitsSinceLatestTag > 0) { "${gitTag.rawTagName}+${gitTag.commitsSinceLatestTag}.${gitTag.commitHash}" } else { gitTag.rawTagName } } } ``` ### Response N/A #### Response Example Tag "1.5.0" with 3 commits since: "1.5.0+3.abc1234" Tag "1.5.0" with 0 commits since: "1.5.0" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.