maven - 在 buildnumber-maven-plugin 中切换 git 提供程序

标签 maven jgit buildnumber-maven-plugin

当使用 buildnumber-maven-plugin 时,如果在命令行构建期间 %PATH% 中没有 git 可执行文件,则执行失败:

[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

但是,当通过 eclipse Run as -> Maven clean verify 执行相同的构建时,可以检索提交 ID。

因为它在 eclipse 中工作,我尝试使用 maven-scm-provider-jgit 而不是 maven-scm-provider-gitexebuildnumber- maven-plugin,但显然我没有正确配置它。

这是我的 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>

如何切换到 maven-scm-provider-jgit

最佳答案

buildnumber-maven-plugin 需要知道要使用哪个 git 提供程序。以下配置将 git 提供程序更改为 jgit

必须至少使用 maven-scm-provider-jgit1.9.5 版本,因为 1.9.4 中未实现 InfoCommand

<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>

关于maven - 在 buildnumber-maven-plugin 中切换 git 提供程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48164129/

相关文章:

java - 将本地 Maven 存储库中的 Artifact 部署到远程存储库

java - gradle 存储库指向具有多个库的本地目录

java - JGit RevWalk.parseTag 不释放对包文件的锁定

git svn 使用 jgit 获取

maven - buildnumber-maven-plugin 属性 ${buildNumber} 的可见性

java - 使用 Maven 和 maven-bundle-plugin 在 JAR list 中添加 SVN 修订时出错

java - 无法删除 slf4j 依赖项

java - 如何查找当前jar文件引用了哪个依赖项?

jenkins - 使用 JGit 在 Jenkins 管道中获取 git commit SHA

Maven内部版本号插件,如何将内部版本号保存在文件中?