Skip to content
A Gradle plugin for automatically generating versions from git.
Branch: master
Clone or download

Build status License Join the chat at

A Gradle plugin for automatically generating versions from git tags and commits.


  1. Add the plugin to your build.gradle file as shown here.
  2. Tag your repository (anywhere in history) with a tag named like v1.2.
  3. Remove the version property from your build.gradle file.
  4. (Optional) Use gradle version or ./gradlew version to see the current version.

Advanced Usage

If you want more control over how you version, you can directly access the VersionInfo object inside your gradle script.

def versionInfo = ZoltuGitVersioning.versionInfo
print "${versionInfo.major}.${versionInfo.minor}.${versionInfo.commitCount}"

Additionally, you may also change how the plugin processes version information by specifying custom processors.

Custom Describe Processor

The plugin no longer supports semantic versioning out-of-box. Instead, you may specify a custom provider function which accepts the result of git describe and returns a map of each versioning component like so:

ZoltuGitVersioning {
    customDescribeProcessor { describeResults ->
        def matcher = (describeResults =~ /(?<major>[0-9]+?)\.(?<minor>[0-9]+?)(?:\-(?<tags>[0-9A-Za-z\.\-]+))?\-(?<commitCount>[0-9]+?)\-g(?<sha>[a-zA-Z0-9]+)/)

Custom Output Processor

The default implementation merely assigns the value of VersionInfo.toString() as the project version. If you want to perform your own processing on the version information produced by the plugin, you may do so as follows:

// With input tag '1.0.0-36'
ZoltuGitVersioning {
    customVersionToString { versionInfo ->

Will produce: ''.


  • Please keep in mind that any calls to ZoltuGitVersioning.versionInfo must occur only after declaring any custom processors.
  • If you need to reference version in your build.gradle file (outside of a lazily executed closure) then you will need to reference ZoltuGitVersioning.versionInfo somewhere before you reference version. This plugin lazily populates version and referencing ZoltuGitVersioning.versionInfo will trigger that lazy population. If you do nothing, it will be triggered after your build.gradle has finished processing (before any tasks are executed).
You can’t perform that action at this time.