Skip to content

Is it possible to assign a git property to project.version? #872

@dennisvang

Description

@dennisvang

Background

Our goal is to get rid of the hard-coded Maven project.version in our pom.xml.

This is possible, as described in Maven CI Friendly Versions, using e.g. a revision property.

However, that still requires us to override the revision value from the command line, as in

mvn -Drevision=<my-git-tag> ...

Question

We would like to assign the value of git.commit.id.describe-short to the project.version directly within the pom.

Is there some way to achieve that?

Context (optional)

The most obvious attempt would be the following:

<project ...>
<version>${git.commit.id.describe-short}</version>
...
</project>

However, that does not work: The resulting jar still shows Implementation-Version: ${git.commit.id.describe-short}.

We also tried setting the default value for the revision property to ${git.commit.id.describe-short}, but that does not appear to work either.

Unfortunately it seems we cannot specify another property for the project.version, as explained in Maven CI Friendly Versions:

A note about the used properties. You can only use those named ${revision}, ${sha1} and/or ${changelist} and not other named properties like this: [...]

Our plugin configuration has <injectAllReactorProjects>true</injectAllReactorProjects> as described in the FAQ.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions