我通过使用此设置设置了使用test-jar
和普通jar构建的项目:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
这个问题是每当我升级pom中的项目版本时,我需要使用测试进行构建,否则maven将无法在test-compile
短语中找到具有正确版本的测试jar。很多时候我只想跳过测试,但由于测试罐丢失,test-compile
phrase将失败。
我试图使用-Dmaven.test.skip=true
,但这似乎没有跳过test-compile
短语。有没有办法跳过这个?
$ mvn clean install -Dmaven.test.skip=true \
-Dmaven.site.skip=true -Dmaven.javadoc.skip=true
如果要跳过测试源的编译,可以尝试适当地配置maven compiler plugin。不建议这样做。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
只需添加-Dmaven.test.skip。它甚至不会编译测试
上面的解决方案给了我未知的生命周期阶段“.test.skip = true”错误。
这是我在https://maven.apache.org/plugins-archives/maven-surefire-plugin-2.12.4/examples/skipping-test.html的工作指令
mvn install -DskipTests