This plugin helps maintain the version of a Gradle project in a separate build.number
file.
There are a few reasons why this is useful:
- Easy to parse for CI/CD scripts.
- One well-known place where the version is stored compared to a random line in
build.gradle.kts
. - Additional date comment maintains the built date.
- A few tasks for version manipulation.
:createBuildNumber
— creates abuild.number
file with a version equal to0.0.1
.:incrementBuildNumber
— increments a fix version in abuild.number
file.:refreshBuildNumber
— updates a date (top commented line) in abuild.number
file.
-
Add a plugin block into the
plugins{}
section:plugins { id("io.github.raymank26.build-number") version "0.0.1" }
-
Update the project version:
version = rootProject.getBuildNumberVersion()
. Now, your version is read from abuild.number
file.
At this point, you can use build.number
as the source of truth for the version of the project.
# Thu Nov 30 21:01:13 MSK 2023
version=0.0.4