【问题标题】:maven-dependency-plugin:unpack Errormaven-dependency-plugin:解压错误
【发布时间】:2015-05-15 11:42:52
【问题描述】:

我正在尝试从依赖项 jar 文件中提取一些 .exe 文件并将它们放在 ${project.build.directory}/classes/ 下。

但是当我执行时:

mvn clean 编译依赖:解包

我得到:

无法在简单项目上执行目标 org.apache.maven.plugins:maven-dependency-plugin:2.10:unpack (default-cli):artifact 或 artifactItems 是必需 -> [帮助 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>

【问题讨论】:

  • 我知道它在 pom 中说 .txt 而我在问题中谈到了 .exe 文件。

标签: maven-3 maven-dependency-plugin


【解决方案1】:

这个问题是因为你不能同时使用mvn clean compile dependency:unpack&lt;executions&gt;标签。

在页面底部的文档Maven Depdendency Plugin 中,您可以阅读:

如果您打算将此 mojo 配置为在命令行上使用:mvn dependency:unpack 执行,则不得将配置放在 executions 标记中。您的配置应如下所示:

<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>

我已经尝试删除&lt;execution&gt; 标签并且效果很好!

【讨论】:

    猜你喜欢
    • 2011-09-21
    • 1970-01-01
    • 2016-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多