https://github.com/mathroule/gradle-version-plugin
Gradle Version Plugin
https://github.com/mathroule/gradle-version-plugin
Last synced: 12 months ago
JSON representation
Gradle Version Plugin
- Host: GitHub
- URL: https://github.com/mathroule/gradle-version-plugin
- Owner: mathroule
- License: mit
- Created: 2019-05-08T16:23:07.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2021-11-23T08:27:08.000Z (over 4 years ago)
- Last Synced: 2025-02-10T14:13:13.551Z (over 1 year ago)
- Language: Groovy
- Size: 123 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Gradle Version Plugin
[](https://jitpack.io/#mathroule/gradle-version-plugin)
A Gradle plugin to manage [semantic versioning](https://semver.org) `minor.major.patch` and generate corresponding Java version or Android version name and version code.
Task usage
----------
```groovy
buildscript {
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
classpath 'com.mathroule:gradle-plugin:1.0.3'
}
}
apply plugin: 'com.mathroule.gradle-plugin'
```
After applying the plugin you'll find `bumpVersion` tasks in your project.
To bump version, use
```
gradle bumpVersion # Shortcut for bumpPatchVersion
gradle bumpPatchVersion # Example bump version 1.1.2 to 1.1.3
gradle bumpMinorVersion # Example bump version 1.1.2 to 1.2.0
gradle bumpMajorVersion # Example bump version 1.1.2 to 2.0.0
```
If no VERSION file is presents, the file is created and init using version 0.0.1
Android version code generation
-------------------------------
The Android version code is built from the version name like this:
```
12345699
| | | \- 2 fourth digit => release candidate version
| | \- 2 third digit => patch version
| \- 2 second digit => minor version
\- 2 first digit => major version
```
Example:
| Version name | Version code |
|----------------|--------------|
| 1.0.0 | 1000099 |
| 1.2.3 | 1020399 |
| 1.2.3-SNAPSHOT | 1020300 |
| 1.2.3-RC1 | 1020301 |
| 1.2.3-RC4 | 1020304 |
| 99.2.3 | 99020399 |
| 100.2.3 | 100020399 |
Java usage
----------
```groovy
version versionPluginName
```
Android usage
-------------
```groovy
android {
defaultConfig {
versionCode versionPluginCode
versionName versionPluginName
}
}
```