首页 文章

maven-release-plugin可以检查通过maven-dependency-plugin下载的工件中的SNAPSHOT版本吗?

提问于
浏览
2

我们有一个项目A,它从另一个项目B下载工件,对其执行操作,并因此吐出新的工件 . 我们使用maven-dependency-plugin中的'dependency:copy'目标从我们的Maven存储库中获取这个Project B工件 .

当我们执行Maven发布时,我希望maven-release-plugin 's ' release:准备'目标来检查所有依赖项,如果找到任何SNAPSHOT版本则失败 . 这适用于我们的 <dependencies><dependency>...</dependency></dependencies> 标签下的正常依赖项,但不适用于maven-dependency-plugin复制的工件"dependencies" .

如何(如果有的话)我可以将这些复制的工件的版本暴露给maven-release-plugin的准备测试,并确保我们从未构建包含项目B快照的项目A的版本?

如果上下文有帮助,这里是我们pom中maven-dependency-plugin设置的简化版本:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.8</version>
    <executions>
        <execution>
            <id>copy</id>
            <phase>process-sources</phase>
            <goals>
                <goal>copy</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>${ProjectBGroupID}</groupId>
                        <artifactId>${ProjectB}</artifactId>
                        <version>${ProjectBVersion}</version>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>

1 回答

  • 0

    添加我自己的问题的答案,我发现我们可以通过在Project A 's pom. This properly causes a failure if we try to release with a snapshot, but it also exposes Project B to Project A'的类路径中包含一个额外的 <dependency>...</dependency> 元素(引用项目B)来将版本号暴露给maven-release-plugin . 我们可以通过包含一个"test"(保留B 's classes out of A'的二进制数)来限制这一点,但是这仍然会让B感染A [2624537_ .

    我实际上将项目B添加到项目A的类路径(的任何部分)中 .

相关问题