JavierSegoviaCordoba / semver-gradle-plugin

Set projects versions based on git tags and following semantic versioning
https://semver-gradle-plugin.javiersc.com
Other
25 stars 3 forks source link

Version isn't prefixed in the Gradle properties #161

Closed rivancic closed 1 month ago

rivancic commented 1 month ago

Version generated with semver plugin isn't prefixed in the Gradle properties.

If I run following command

./gradlew properties -Psemver.scope=minor -Psemver.stage=snapshot -Psemver.tagPrefix=v

I even have semver.tagPrefix=v in gradle.properties file set.

The output is without the prefix in the version

...
version: 1.5.0-SNAPSHOT
...

Is this expected? Then later I have to manually append tag prefix after extracting project version. Need to do a custom git tag push.

JavierSegoviaCordoba commented 1 month ago

I am not sure what you mean.

I have a project that uses prefixes and the output for

./gradlew printSemver -P semver.scope=minor -P semver.stage=snapshot -P semver.tagPrefix=p

is

> Task :hubdle-version-catalog:printSemver
semver for hubdle-version-catalog: c0.3.2.2+69f559a

> Task :hubdle-gradle-plugin:printSemver
semver for hubdle-gradle-plugin: p0.8.0-SNAPSHOT

> Task :printSemver
semver for hubdle: p0.8.0-SNAPSHOT

If you are referring to the project.version, it will never show the tag prefix there, as it is invalid. I don't remember if Gradle crashes or if Maven Central publications will fail (I think this last one).

Is this expected? Then later I have to manually append tag prefix after extracting project version. Need to do a custom git tag push.

You shouldn't need to do any manual job.

JavierSegoviaCordoba commented 1 month ago

Additionally, if you need to get the version, you can read it from a file that is already generated, for example:

The path would be: some-project/semver/version.txt

And the content:

0.8.0-SNAPSHOT
p0.8.0-SNAPSHOT

You can map the version too, but I don't recommend appending the tag prefix to project.version.

rivancic commented 1 month ago

Exactly I was referring to the project.version Gradle property. In current customized pipeline this value is being used as project version and it works fine it is without prefix

When I push tags with git tag command in pipeline then I prepend proper prefix.

Thanks for the clarification.