2
votes

I'm trying to set the release version number of our app to something like 1.5.0.057b2009 with the abbreviated git commit hash in it.

Setup

I'm trying to use maven-release-plugin in combination with git-commit-id-plugin.

Our base version number in development is 1.5.0-SNAPSHOT.

<plugin>
    <artifactId>maven-release-plugin</artifactId>
    <version>2.5.1</version>
    <configuration>
        <tagNameFormat>APP-NAME-@{version}</tagNameFormat>
        <autoVersionSubmodules>true</autoVersionSubmodules>
        <preparationGoals>clean install</preparationGoals>
        <localCheckout>true</localCheckout>
        <pushChanges>true</pushChanges>
        <branchName>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.x</branchName>
        <releaseVersion>${project.version}.${git.commit.id.abbrev}</releaseVersion>
    </configuration>
</plugin>
<plugin>
    <groupId>pl.project13.maven</groupId>
    <artifactId>git-commit-id-plugin</artifactId>
    <version>2.1.7</version>
    <executions>
        <execution>
            <phase>validate</phase>
            <goals>
                <goal>revision</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
        <generateGitPropertiesFile>false</generateGitPropertiesFile><!-- somehow necessary. otherwise the variables are not available in the pom -->
    </configuration>
</plugin>

Build

The whole project is built with the following command:

mvn -B release:prepare

Problem

The maven release plugin completely ignores the releaseVersion property. The actual release version would be 1.5.0, how can I handle this?

How do you run the release build? - Jens
I build the project with mvn -B release:prepare. I updated my question. - Franz Wimmer
try to use -X and see if the value is used - Jens
According to the debug output, the git commit hash is not evaluated: [DEBUG] (f) releaseVersion = 1.9.0-SNAPSHOT.${git.commit.id.abbrev} - Franz Wimmer
try to add pl.project13.maven:git-commit-id-plugin:2.1.7:revision to the preparationGoals - Jens