-
Notifications
You must be signed in to change notification settings - Fork 11
Migration Guide
If you were a version 1 user of this plugin, then you will undoubtedly run into issues with version 2. Version 2 introduces a simpler API and removes convenience features in favor of keeping the plugin as simple as possible.
In version 1, there was a notion of a version file. It was a JSON file that looked like the following:
{
"patch": 0,
"minor": 0,
"major": 1,
"buildNumber": 100,
"revision": 1
}
Version 2 still relies on this file. The only difference is that revision
is no longer used and the location of the file has changed.
Previously, the file would live at the root of your project by default (/path/to/project/version
). Now it lives inside your apps module folder. For example, if your app module is named myapp
, the file would be located at /path/to/project/myapp/version
.
If you're unsure, you can just build your project and the plugin will also create the file for you if it doesn't exist.
Suggested Action To Take: Move version file over to app module folder and remove revision
from file.
Version 1 was a versioning tool that would also build your projects for you. If you were to tell AndroidAutoVersion to update your project version, it would subsequently run a release build of your project.
Version 2 is more focused and because of that, AndroidAutoVersion never builds your project when versioning. It only updates the version file. Because of this, there's only 3 commands you need to worry about:
./gradlew bumpPatch
./gradlew bumpMinor
./gradlew bumpMajor
Suggested Action To Take: None
In version 1, you had something like the following in your build.gradle
file:
androidAutoVersion {
release {
releaseTask = "assembleRelease"
}
}
In version 2, AndroidAutoVersion doesn't need to know which task is your release task, which is why this has been removed.
Suggested Action To Take: Delete releaseTask
.
Another version 1 feature was the ability to assign a beta suffix to the versionName
by having a beta configuration block:
androidAutoVersion {
beta {
releaseTask = "assembleRelease"
}
}
Doing so would grant you access to the following Gradle tasks: releaseBetaMajor
, releaseBetaMinor
, releaseBetaPatch
.
In version 2, this has been removed in favor for the build variants feature of the Android Gradle Plugin. If you have build variants, you can have AndroidAutoVersion append a suffix of your choosing for a given variant...
android {
beta {
versionNameSuffix ".beta"
}
alpha {
versionNameSuffix ".alpha"
}
}
Suggested Action To Take: Delete beta
block and use build variants.
In version 1, users also had the ability to run tasks after versioning (such as committing to git):
androidAutoVersion {
postHooks = [
{ versionString ->
// Do something like commit to git
}
]
}
Although this feature was convenient, it was a build process problem and not a versioning problem.
In version 2, post hooks has been removed in favor of scripting these build process tasks:
./gradlew clean bumpPatch assembleRelease && git add app/version && git commit -m "Update version."
Suggested Action To Take: Delete all postHooks
and use a bash script (or similar) to fulfill your build process needs.
At the end of the migration you should have any empty block like so:
androidAutoVersion {
}
From here, you can just simply remove this block. In fact, if you leave it there, Gradle will not recognize it and throw an error.