在 maven 中使用 jgitver 和本地 repo 时 spring-boot-dependency 版本无效

Invalid spring-boot-dependency version when using jgitver and local repo in maven

当我将 spring-boot-starter-parent 与本地存储库和 jgitver 结合使用时,出现以下错误:

[ERROR]   The project tmplsvcpkg:TMPL_SVC_NAME-parent:0.0.0-27-a592e4fb-feature_gitlabci-dirty (/home/user/git/service-template/pom.xml) has 1 error
[ERROR]   Non-resolvable parent POM for org.springframework.boot:spring-boot-starter-parent:[unknown-version]: Could not find artifact org.springframework.boot:spring-boot-dependencies:pom:0.0.0-27-a592e4fb-feature_gitlabci-dirty in internal-repository (https://mvnrepo) @ org.springframework.boot:spring-boot-starter-parent:[unknown-version], /home/user/git/service-template/.m2/repository/org/springframework/boot/spring-boot-starter-parent/2.2.0.RELEASE/spring-boot-starter-parent-2.2.0.RELEASE.pom, line 3, column 11 -> [Help 2]

注意 unknown-version 对于 spring-boot-starter-parent 和 0.0.0-27-a592e4fb-feature_gitlabci-dirty spring-启动依赖项。 0.0.0-27-...版本是jgitver计算出来的版本。看起来版本分辨率不知何故搞砸了。如果我将本地存储库更改为项目之外的任何目录,它会再次开始工作。如果我压制 jgitver 它又开始工作了。如果我在我的项目中更深入地定义本地存储库(如 maven.repo.local=x/y/z/.m2/repository,错误仍然存​​在。

我在 pom.xml 中这样定义了父级:

        <parent>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-parent</artifactId>
                <version>2.2.0.RELEASE</version>
        </parent>

而我 运行 我的行家是这样的:

mvn compile -Dmaven.repo.local=.m2/repository -U

如果我添加 jgitver.skip=true,一切正常。

我怀疑这可能与以下事实有关:spring-boot-starter parent 定义它的父级(spring-boot-dependencies)相对于它的位置:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-dependencies</artifactId>
    <version>2.2.0.RELEASE</version>
    <relativePath>../../spring-boot-dependencies</relativePath>
</parent>

有没有人知道为什么会发生这种情况以及如何解决它?

事实证明这是一个众所周知的问题,并通过插件的特定配置解决(您必须在插件配置中排除 .m2 目录)。更多详情尽在本期:

https://github.com/jgitver/jgitver-maven-plugin/issues/60