使用SNAPSHOT测试依赖项发布项目

Mic*_*das 2 release maven maven-release-plugin

我正在项目中的测试使用快照依赖项

    <dependency>
        <groupId>com.my-company</groupId>
        <artifactId>my-test-library</artifactId>
        <version>LATEST</version>
        <scope>test</scope>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

我知道使用的风险,LATEST但这正是我想要在测试中实现的.但是,当我使用异常调用时,此测试依赖性会阻止生成代码的释放mvn release:prepare:

[INFO] Checking dependencies and plugins for snapshots ...
There are still some remaining snapshot dependencies.
...
Caused by: org.apache.maven.shared.release.ReleaseFailureException: Can't release project due to non released dependencies :
    com.my-company:my-test-library:jar:LATEST:test
in project 'My Project'
Run Code Online (Sandbox Code Playgroud)

我的dependencyManagement:

<distributionManagement>
    <repository>
        <uniqueVersion>true</uniqueVersion>
        <id>rep-releases</id>
        <name>Release Repo</name>
        <url>${url}</url>
    </repository>
    <snapshotRepository>
        <uniqueVersion>true</uniqueVersion>
        <id>rep-snapshots</id>
        <name>Snapshots Repo</name>
        <url>${url}</url>
    </snapshotRepository>
</distributionManagement>
Run Code Online (Sandbox Code Playgroud)

为什么测试代码与发布程序有关?如何继续发布并保留依赖项?

car*_*ing 6

您正在做的事情实际上是针对所有规则的,您还应首先发布测试依赖项,然后发布然后将项目版本切换到快照并将测试范围的依赖项还原到快照.

如果你真的,真的,真的必须做蠢事,那么你可以指定-DignoreSnapshots=true选项.但是,这将忽略SNAPSHOT在您pom.xml中定义的任何依赖项,这更糟糕.

你被警告了.继续冒风险,愿上帝怜悯!

  • 因为创建发行版的全部目的是,您将在将来的任何给定时间点都拥有完全可复制的代码状态。如果您有任何类型的“ SNAPSHOT”,并且在五个月之内重新构建了代码,则该测试依赖项可能已更改,并且您标记的代码可能不再起作用,并且绝对不可复制。 (2认同)