Where does axion-release plugin currentVersion come from?

857 Views Asked by At

I am using gradle, I added the plugin

plugins {
    id 'pl.allegro.tech.build.axion-release' version '1.14.0'
}

now when I am running

./gradlew currentVersion

I am getting

Project version: 0.1.0-SNAPSHOT

I tried adding a gradle.properties that contains

version=0.0.1-SNAPSHOT

But when running

./gradlew currentVersion

it still returns 0.1.0-SNAPSHOT

I'd like to know where that's coming from and if it's possible to use the value from gradle.properties, or what's the best way to use the version with the plugin.

Thanks.

1

There are 1 best solutions below

0
3ric-T On

If it still return 0.1.0-SNAPSHOT, that's by design. As stated by Adam Dubiel from Allegro:

... by design axion-release does not include version number in build.gradle. Philosophy of axion-relese is that version is not declared in files, but is a product of source code version tracked by SCM - git.

Then your can have a look at the documentation or at Allegro tech blog:

The flow of axion-release-plugin is simple. Each time you start a build it looks for the version tag closest to current commit and extracts the version number from it. If you happen to be on a tagged commit, you operate on release version. If not, patch version is increased and SNAPSHOT suffix is appended.

Here is an example of the flow:

$ git tag
project-1.0.0

$ ./gradlew currentVersion
1.0.0

$ git add . && git commit -m "I've just changed something"

$ ./gradlew currentVersion
1.0.1-SNAPSHOT

$ ./gradlew release

$ git tag
project-1.0.0 project-1.0.1

$ ./gradlew cV # gradle magic - currentVersion
1.0.1

I hope this helps, despite the late reply