Gradle plugin to manage an application version code inside its continuous integration lifecycle.
This plugin was developed for the REST service: version-code-service.
The plugin is available in JitPack. Just add the following to your buildscript dependencies:
buildscript {
repositories {
....
maven {
url "https://jitpack.io"
}
}
dependencies {
...
classpath 'com.github.Mindera:gradle-versioncode-plugin:1.4'
}
}Apply it:
apply plugin: 'com.mindera.gradle.versioncode'If you are using android flavors, this will generate a task for each combination of flavor and build type that are not debuggable.
For instance, if you have:
productFlavors {
pro {
applicationId = "com.example.my.pkg.pro"
}
free {
applicationId = "com.example.my.pkg.free"
}
}This plugin will generate the tasks:
incrementVersionCodeProRelease
incrementVersionCodeFreeReleaseNote: When using flavors, if you set the appVersionCode.appId it will be used for every flavor, if not it will use the value in applicationId.
appVersionCode {
appId = <app identifier> (do not use if you are using flavors)
serviceEndpoint = <version code service endpoint>
}Use the task 'incrementVersionCode'. For instance, in the command line type:
$ ./gradlew incrementVersionCodeIf you're using android flavors, you could run:
$ ./gradlew incrementVersionCodeProReleaseimport com.mindera.gradle.versioncode.utils.VersionCodeService
apply plugin: 'com.mindera.gradle.versioncode'
(...)
VersionCodeService versionCodeService = new VersionCodeService(<version code service endpoint>, <app identifier>)
return versionCodeService.currentVersionCode()version-code-service is available under the MIT license. See the LICENSE file for more info.