我在mvn release:prepare -Darguments="-Dmaven.test.skip=true -DskipTests"
的主结账时运行Spotify's docker-client。但我不能让maven的发布插件跳过测试。为什么maven在这种情况下不尊重CLI标志?
我也很好奇是什么原因导致release插件执行surefire-plugin。在pom.xml
中没有指定surefire-plugin。
mvn --version
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T12:29:23-05:00)
Maven home: /usr/local/Cellar/maven/3.2.5/libexec
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.2", arch: "x86_64", family: "mac"
有两件事。首先,如果你想运行一个版本,你需要运行mvn release:perform
,它真正运行最终版本的步骤,而不是mvn release:prepare
。如果你想跳过mvn release:prepare
中的测试,你应该使用mvn -Dmaven.test.skip=true
加上你定义的给定参数。
除了maven-surefire-plugin在default life cylce中定义
这对我有用。我想要准备和执行发布。
mvn clean -DskipTests -Darguments=-DskipTests release:prepare release:perform
我在我的pom.xml中使用了以下内容
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
<arguments>-Dmaven.javadoc.skip=true -Dmaven.test.skipTests=true -Dmaven.test.skip=true</arguments>
</configuration>
</plugin>
这适用于Maven 3.6(可能还有一些早期版本)。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<arguments>-DskipTests</arguments>
</configuration>
</plugin>