2015-05-15 70 views
4

我試圖從一個依賴關係jar文件中提取一些.exe文件,並將它們放在$ {project.build.directory}/classes /下。maven-dependency-plugin:解壓錯誤

但是,當我執行:

MVN清潔編譯依賴性:解壓

我得到:

未能執行目標org.apache.maven.plugins:Maven的依賴關係的插件:2.10:在項目上解壓縮(default-cli)簡單:需要僞像或僞像項目 - > [幫助1

我已驗證依賴關係可用在我的本地存儲庫中。

在我的pom例子中,我用junit作爲例子,但無論我列出哪個依賴項,我都會得到同樣的錯誤。

的pom.xml:

<build> 
    <pluginManagement> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-dependency-plugin</artifactId> 
     <version>2.10</version> 
     <executions> 
      <execution> 
      <id>unpack</id> 
      <phase>package</phase> 
      <goals> 
       <goal>unpack</goal> 
      </goals> 
      <configuration> 
       <artifactItems> 
       <artifactItem> 
        <groupId>junit</groupId> 
        <artifactId>junit</artifactId> 
        <version>4.10</version> 
        <type>jar</type> 
        <overWrite>false</overWrite> 
    <outputDirectory>${project.build.directory}/classes/externaltools</outputDirectory>     
        <includes>**/*.txt</includes> 
       </artifactItem> 
       </artifactItems> 
      </configuration> 
      </execution> 
     </executions> 
     </plugin> 
    </plugins> 
    </pluginManagement> 
</build> 
+0

我知道它說的是.txt lin pom,而我在這個問題中討論了.exe文件。 – PistolPete

回答

6

的問題是,由於不能使用mvn clean compile dependency:unpack<executions>標籤一起。

在頁面的底部文檔Maven Depdendency Plugin你可以閱讀:

如果打算配置此魔力使用命令行中執行:mvn dependency:unpack你不能把配置處決標籤內。你的配置應該是這樣的:

<project> 
    [...] 
    <build> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-dependency-plugin</artifactId> 
     <version>2.10</version> 
     <configuration> 
      <artifactItems> 
      <artifactItem> 
       <groupId>[ groupId ]</groupId> 
       <artifactId>[ artifactId ]</artifactId> 
       <version>[ version ]</version> 
       <type>[ packaging ]</type> 
       <classifier> [classifier - optional] </classifier> 
       <overWrite>[ true or false ]</overWrite> 
       <outputDirectory>[ output directory ]</outputDirectory> 
       <destFileName>[ filename ]</destFileName> 
       <includes>[ comma separated list of file filters ]</includes> 
       <excludes>[ comma separated list of file filters ]</excludes> 
      </artifactItem> 
      </artifactItems> 
      <!-- other configurations here --> 
     </configuration> 
     </plugin> 
    </plugins> 
    </build> 
    [...] 
</project> 

我曾試圖消除<execution>標籤和完美的作品!