简体   繁体   English

Maven 发布插件跳过执行但不准备的测试

[英]Maven release plugin skipping tests on perform but not prepare

When using the maven release plugin, both mvn release:prepare and mvn release:perform will run the tests.使用 maven 发布插件时, mvn release:preparemvn release:perform都将运行测试。

Is there any way I can configure things so they only run during mvn release:prepare ?有什么办法可以配置东西,让它们只在mvn release:prepare期间运行?

I know you can pass:我知道你可以通过:

-Darguments="-DskipTests"

But this will skip the tests during both goals, which I don't want.但这将跳过两个目标期间的测试,这是我不想要的。 And I also don't want them to run during just mvn release:perform and not prepare, as a failure during perform will have already tagged the repository.而且我也不希望它们仅在mvn release:perform而不是 prepare 期间运行,因为执行期间的失败已经标记了存储库。

You should be able to do that by adding the <releaseProfiles> element to the release-plugin configuration.您应该能够通过将<releaseProfiles>元素添加到 release-plugin 配置来做到这一点。 This will only be used for release:perform Mojo.这将仅用于发布:执行 Mojo。

Something like this should do the trick:像这样的事情应该可以解决问题:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-release-plugin</artifactId>
            <configuration>
                <releaseProfiles>skipTestsForReleasePerform</releaseProfiles>
            </configuration>
        </plugin>
    </plugins>
</build>
(...)
<profiles>
    <profile>
        <id>skipTestsForReleasePerform</id>
        <properties>
            <maven.test.skip>true</maven.test.skip>
        </properties>
    </profile>
</profiles>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM