mavenjgitbuildnumber-maven-plugin

Switch git provider in buildnumber-maven-plugin


When using the buildnumber-maven-plugin, the execution fails when no git executable is in the %PATH% during a build on command line:

[ERROR] Failed to execute goal org.codehaus.mojo:buildnumber-maven-plugin:1.4:create (default) on project test: Cannot get the revision information from the scm repository :
[ERROR] Exception while executing SCM command. Error while executing command. Error while executing process. Cannot run program "git" (in directory "C:\dev\test"): CreateProcess error=2, Das System kann die angegebene Datei nicht finden

However, when executing the same build via eclipse Run as -> Maven clean verify, a commit id can be retrieved.

Since it works in eclipse, I tried to use the maven-scm-provider-jgit instead of maven-scm-provider-gitexe with buildnumber-maven-plugin, but apparently I did not configure it correctly.

This is the relevant part of my pom.xml:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>buildnumber-maven-plugin</artifactId>
    <version>1.4</version>
    <executions>
        <execution>
            <phase>validate</phase>
            <goals>
                <goal>create</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <doCheck>false</doCheck>
        <doUpdate>false</doUpdate>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.apache.maven.scm</groupId>
            <artifactId>maven-scm-provider-jgit</artifactId>
            <version>1.9.4</version>
        </dependency>
    </dependencies>
</plugin>

How can I switch to maven-scm-provider-jgit?


Solution

  • The buildnumber-maven-plugin needs to know, which git provider to use. The following configuration changes the git provider to jgit.

    It is necessary to use at least version 1.9.5 of maven-scm-provider-jgit, since the InfoCommand is not implemented in 1.9.4.

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>buildnumber-maven-plugin</artifactId>
        <version>1.4</version>
        <executions>
            <execution>
                <phase>validate</phase>
                <goals>
                    <goal>create</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <doCheck>false</doCheck>
            <doUpdate>false</doUpdate>
            <providerImplementations>
                <git>jgit</git>
            </providerImplementations>
        </configuration>
        <dependencies>
            <dependency>
                <groupId>org.apache.maven.scm</groupId>
                <artifactId>maven-scm-provider-jgit</artifactId>
                <version>1.9.5</version>
            </dependency>
        </dependencies>
    </plugin>