gpt4 book ai didi

maven-3 - maven-dependency-plugin:unpack 错误

转载 作者:行者123 更新时间:2023-12-02 00:37:42 24 4
gpt4 key购买 nike

我试图从依赖 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>

最佳答案

问题是由于您无法使用 mvn clean compile dependency:unpack<executions>标签在一起。

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

If you intend to configure this mojo for execution on the command line using: mvn dependency:unpack you must not put the configuration inside the executions tag. Your configuration should look like this:


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

关于maven-3 - maven-dependency-plugin:unpack 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30258651/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com