{"id":13428833,"url":"https://github.com/moallemi/gradle-advanced-build-version","last_synced_at":"2025-04-04T12:07:50.600Z","repository":{"id":25487520,"uuid":"28918479","full_name":"moallemi/gradle-advanced-build-version","owner":"moallemi","description":"A plugin to generate the Android version code and version name automatically based on git commits number, date and ...","archived":false,"fork":false,"pushed_at":"2024-07-15T01:01:04.000Z","size":402,"stargazers_count":607,"open_issues_count":11,"forks_count":48,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-03-28T11:07:44.272Z","etag":null,"topics":["android","android-studio","gradle","gradle-plugin","hacktoberfest","java","kotlin","library","versioning"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moallemi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"moallemi"}},"created_at":"2015-01-07T14:44:07.000Z","updated_at":"2025-03-27T19:47:30.000Z","dependencies_parsed_at":"2024-01-25T18:59:34.104Z","dependency_job_id":null,"html_url":"https://github.com/moallemi/gradle-advanced-build-version","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moallemi%2Fgradle-advanced-build-version","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moallemi%2Fgradle-advanced-build-version/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moallemi%2Fgradle-advanced-build-version/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moallemi%2Fgradle-advanced-build-version/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moallemi","download_url":"https://codeload.github.com/moallemi/gradle-advanced-build-version/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174418,"owners_count":20896078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-studio","gradle","gradle-plugin","hacktoberfest","java","kotlin","library","versioning"],"created_at":"2024-07-31T01:01:06.278Z","updated_at":"2025-04-04T12:07:50.584Z","avatar_url":"https://github.com/moallemi.png","language":"Kotlin","funding_links":["https://github.com/sponsors/moallemi"],"categories":["Libraries","Plugins","Groovy","Gradle插件"],"sub_categories":["Android application development","文件同步"],"readme":"# Gradle Advanced Build Version Plugin\n\nIf you need automatic incremental Gradle versioning, this plugin helps you to generate the Android version code and version name automatically based on git commits number, date and [Semantic Versioning](https://semver.org/).\n\n[![GitHub Workflow Status](https://github.com/moallemi/gradle-advanced-build-version/workflows/CI/badge.svg)](https://github.com/moallemi/gradle-advanced-build-version/actions?query=workflow%3ACI)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/me.moallemi.gradle/advanced-build-version/badge.svg)](https://search.maven.org/artifact/me.moallemi.gradle/advanced-build-version)\n[![Coverage](https://codecov.io/gh/moallemi/gradle-advanced-build-version/branch/dev/graph/badge.svg)](https://codecov.io/gh/moallemi/gradle-advanced-build-version)\n\n## Contents\n1. [Installation](#installation)\n2. [How to use](#how-to-use)\n3. [Version Name Configuration](#version-name-configuration)\n4. [Version Code Configuration](#version-code-configuration)\n5. [File output options](#file-output-options)\n\n## Installation\n\nAdd the advanced-build-version plugin to your build script and use the property `advancedVersioning.versionName` and\n`advancedVersioning.versionCode` where you need:\n\n| Gradle Advanced Build Version  | Minumum AGP Version |\n|  :---: |  :---: |\n| 3.0.0  | 8.1.0  |\n| 2.0.2  | 8.0.0  |\n| 2.0.0  | 7.0.0  |\n| 1.7.3  | 3.0.0  |\n\nUsing the plugins DSL:\n```groovy\nplugins {\n    id \"me.moallemi.advanced-build-version\" version \"3.0.0\"\n}\n```\n\nUsing legacy plugin application:\n```groovy\nbuildscript {\n  repositories {\n    mavenCentral()\n  }\n\n  dependencies {\n    classpath 'me.moallemi.gradle:advanced-build-version:3.0.0'\n  }\n}\n\napply plugin: 'me.moallemi.advanced-build-version'\n```\n\n## How to use\n\n```\nadvancedVersioning {\n  nameOptions { }\n  codeOptions { }\n  outputOptions { }\n}\n\ndef appVersionName = advancedVersioning.versionName\ndef appVersionCode = advancedVersioning.versionCode\n```\n\n## Version Name Configuration\n\nYou can customize version name in your `build.gradle` file as follows:\n\n```groovy\nadvancedVersioning {\n  nameOptions {\n    versionMajor 1\n    versionMinor 3\n    versionPatch 6\n    versionBuild 8\n  }\n}\n```\nthe above configuration will output `1.3.6.8`\n\nthere is no need to specify all params because they will be handled automatically. for example:\n\n```groovy\nadvancedVersioning {\n  nameOptions {\n    versionMajor 1\n    versionBuild 8\n  }\n}\n```\nwill output `1.0.0.8` and\n\n```groovy\nadvancedVersioning {\n  nameOptions {\n    versionMajor 1\n    versionMinor 3\n  }\n}\n```\n\nwill output `1.3`\n\n## Version Code Configuration\n\nTo customize version code in your `build.gradle` file write:\n\nGroovy:\n```groovy\nadvancedVersioning {\n  codeOptions {\n    versionCodeType 'GIT_COMMIT_COUNT'\n  }\n}\n```\n\nKotlin:\n```kotlin\nimport me.moallemi.gradle.advancedbuildversion.gradleextensions.VersionCodeType.*\n\nadvancedVersioning {\n  codeOptions {\n    versionCodeType(GIT_COMMIT_COUNT)\n  }\n}\n```\n\n`versionCodeType` can be one of following params:\n \n * `GIT_COMMIT_COUNT` will output total commits number in current branch\n * `AUTO_INCREMENT_STEP` will output e.g: 26\n\nIf you are using CIs like Jenkins, CircleCI or GitHub Actions, and you want to use `GIT_COMMIT_COUNT`, consider checking out repositories with `--depth=1` parameter. You should clone your repository with full history or unshallow an already existing one.\n\nFor GitHub Actions consider `fetch-depth: 0`:\n\n```yaml\nsteps:\n- name: Checkout\n  uses: actions/checkout@v4\n  with:\n    fetch-depth: 0\n```\n\n`AUTO_INCREMENT_STEP` store AI_VERSION_CODE in `version.properties` file in build.gradle \n directory, you may also change `dependsOnTasks` property to specify that on witch tasks should increase version code\n (default is every task that contains 'release' in its name)\n\n`AUTO_INCREMENT_STEP` allows you to set a step different from 1:\n```groovy\nadvancedVersioning {\n  codeOptions {\n    versionCodeType 'AUTO_INCREMENT_STEP'\n    versionCodeStep 2 //default to 1\n  }\n}\n``` \n\n## File output options\nYou can also rename the output generated apk file with this plugin. it can be done just by enabling \nthe `renameOutput` option:\n\n```groovy\nadvancedVersioning {\n  outputOptions {\n    renameOutput true\n  }\n}\n```\n\nIf your app name is MyApp with 2.7 version name, and you are in debug mode, the output apk file name \nwill be: `MyApp-2.7-debug.apk`\n\n**NOTE for v 2.x.x Only:** Android Gradle Plugin 4.1.0 [drops support](https://developer.android.com/studio/known-issues#variant_output) for renaming apk. We are using a workaround to keep renaming option for gradle-advanced-build-version library.\nSo if you are using AGP 4.1.0+, you have to add `advancedVersioning.renameOutputApk()` after android configuration. The order is important:\n\n```groovy\nadvancedVersioning {\n  outputOptions {\n    renameOutput true\n  }\n}\nandroid {\n  ...\n}\nadvancedVersioning.renameOutputApk()\n```\n\nYou can customize the output name by using this params:\n\n* `${appName}`: name of main module\n* `${projectName}`: name of root project\n* `${flavorName}`: flavor name\n* `${buildType}`: build type\n* `${versionName}`: version name\n* `${versionCode}`: version code\n\nGroovy:\n```groovy\nadvancedVersioning {\n  outputOptions {\n    renameOutput true\n    nameFormat '${appName}-${buildType}-${versionName}'\n  }\n}\n```\n\nKotlin:\n```kotlin\nadvancedVersioning {\n  outputOptions {\n    renameOutput(true)\n    nameFormat(\"\\${appName}-\\${buildType}-\\${versionName}-\\${versionCode}\")\n  }\n}\n```\n\nAnd you can also use custom string in `nameFormat` like:\n\nGroovy:\n```groovy\nadvancedVersioning {\n  outputOptions {\n    renameOutput true\n    nameFormat '${appName}-google-play-${versionName}'\n  }\n}\n```\n\nKotlin:\n```kotlin\nadvancedVersioning {\n  outputOptions {\n    renameOutput(true)\n    nameFormat(\"\\${appName}-google-play-\\${versionName}\")\n  }\n}\n```\n\nIf your app name is MyApp with 4.6.1 version name the output apk file name will be: \n`MyApp-google-play-4.6.1.apk`\n\n## License\n\n```\nCopyright 2024 Reza Moallemi.\n\nLicensed to the Apache Software Foundation (ASF) under one or more contributor\nlicense agreements. See the NOTICE file distributed with this work for\nadditional information regarding copyright ownership. The ASF licenses this\nfile to you under the Apache License, Version 2.0 (the \"License\"); you may not\nuse this file except in compliance with the License. You may obtain a copy of\nthe License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\nWARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\nLicense for the specific language governing permissions and limitations under\nthe License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoallemi%2Fgradle-advanced-build-version","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoallemi%2Fgradle-advanced-build-version","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoallemi%2Fgradle-advanced-build-version/lists"}