2015-05-15 42 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>标签和完美的作品!