我已将Maven配置为为所有构建(快照和发布)创建测试JAR,如下所示:
<plugin>
<!-- generate test-jar artifacts for creating test-test dependencies
across modules -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
这有效,但我想解决一个奇怪的行为:Maven现在尝试为包装pom
(即父POM)的模块创建测试JAR。这只是一个小麻烦,但有一个简单的方法来解决这个问题吗?
它不会为这些模块创建主JAR。也许这是test-jar
目标中的错误?
答案 0 :(得分:0)
skipIfEmpty
does the trick,感谢wemu:
<plugin>
<!-- generate test-jar artifacts for creating test-test dependencies
across modules -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
<configuration>
<skipIfEmpty>true</skipIfEmpty>
</configuration>
</execution>
</executions>
</plugin>
文档:https://maven.apache.org/plugins/maven-jar-plugin/test-jar-mojo.html#skipIfEmpty