2015-07-13 31 views
3

<包含>標記在maven-dependency-plugin條目中看起來似乎不起作用。maven-dependency-plugin <includes>標記不起作用

  <artifactId>maven-dependency-plugin</artifactId> 
      <executions> 
       <execution> 
        <id>unpack</id> 
        <phase>package</phase> 
        <goals> 
         <goal>unpack</goal> 
        </goals> 
        <configuration> 
         <artifactItems> 
          <artifactItem> 
           <groupId>org.test</groupId> 
           <artifactId>test-build-common</artifactId> 
           <version>${project.version}</version> 
           <classifier>others</classifier> 
           <type>tar</type> 
           <outputDirectory>target</outputDirectory> 
           <includes>**/common_test.sh</includes> 
          </artifactItem> 
         </artifactItems> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

通過上述條目中檢索到的測試others.tar的內容containts以下項目

common/a.sh 
common/b.sh 
common/common_test.sh 

我期望的唯一公共/ common_test.sh到構建過程中被提取到目標目錄。但是,所有文件實際上都被提取到目標目錄。由於光盤上的空間限制,不需要的文件不會被提取。

我該如何恰當地選取需要提取的文件?

更新:似乎這是缺陷是版本2.8。它在插件的2.10版本中起作用。

回答

0

你必須使用排除以及因爲如果你將看到包括文件說, (組件代碼=返回isIncluded(名)和isExcluded(名);!)

因此,使用以及和將正常工作。

您可以使用下面的鏈接作爲參考。 https://maven.apache.org/plugins/maven-dependency-plugin/unpack-dependencies-mojo.html

+0

我認爲你錯了。沒有必要使用排除。假設有2個文件A和B,只有pom.xml中的條目是 A.計算isIncluded(A)和!isExcluded(A)的值isIncluded(B)AND!isExcluded(B) –

+0

好的。如果我看到你的語法,你已經給出了文件名,但它應該是類似 **/common_test.sh。 –

0

使用版本2.10或更高版本的maven-dependency-plugin。版本2.8和2.9不包括,排除正確。

+0

問題兄弟已經更新了答案。 –