2017-06-29 141 views
0

我已經Maven的配置來創建測試的JAR所有構建(快照和釋放),像這樣:如何避免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

我假設你有你的父母該插件的定義? – khmarbaise

+0

你可以請顯示完整的pom嗎? – Jens

+2

有一個標誌「skipIfEmpty」:https://maven.apache.org/plugins/maven-jar-plugin/test-jar-mojo.html#skipIfEmpty - 可能有助於避免創建空的jar文件 – wemu

回答

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

相關問題