maven-dependency-plugin:copy 尝试复制类

发布于 2024-10-09 14:14:26 字数 1445 浏览 0 评论 0原文

我有父 pom 和两个模块 pom。在第一个模块中,我想将第二个模块(jar)复制到某个文件夹。当我从第一个模块 pom 编译项目时 - 它可以工作,但是当我尝试从父项目 pom 编译时,插件尝试复制 jar 的模块类:

[错误]执行目标失败 org.apache.maven.plugins:maven-dependency-plugin:2.1:复制 (默认)在项目模块1上: 复制工件时出错 /home/chardex/projects/test/module2/target/classes 到 /home/chardex/projects/test/module1/target/lib/classes: /home/chardex/projects/test/module2/target/classes (是一个目录)-> [帮助1]

   <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
            <execution>
                <phase>compile</phase>
                <goals>
                    <goal>copy</goal>
                </goals>
                <configuration>
                    <artifactItems>            
                        <artifactItem>
                            <groupId>...</groupId>
                            <artifactId>module2</artifactId>
                            <version>...</version>
                            <type>jar</type>
                        </artifactItem>
                    </artifactItems>
                </configuration>
            </execution>
        </executions>
    </plugin>

谢谢。

I have parent pom and two module poms. In first module I want to copy second module (jar) to some folder. When I compiling project from first module pom - it works, but when I'm trying to compile from parent project pom, plugin tries to copy module classes insted of jar:

[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-dependency-plugin:2.1:copy
(default) on project module1:
Error copying artifact from
/home/chardex/projects/test/module2/target/classes
to
/home/chardex/projects/test/module1/target/lib/classes:
/home/chardex/projects/test/module2/target/classes
(Is a directory) -> [Help 1]

   <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
            <execution>
                <phase>compile</phase>
                <goals>
                    <goal>copy</goal>
                </goals>
                <configuration>
                    <artifactItems>            
                        <artifactItem>
                            <groupId>...</groupId>
                            <artifactId>module2</artifactId>
                            <version>...</version>
                            <type>jar</type>
                        </artifactItem>
                    </artifactItems>
                </configuration>
            </execution>
        </executions>
    </plugin>

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

违心° 2024-10-16 14:14:26

我相信这是 maven-dependency-plugin 中的错误: http://jira.codehaus.org/browse/MDEP-259

I believe this is a bug in maven-dependency-plugin: http://jira.codehaus.org/browse/MDEP-259

过度放纵 2024-10-16 14:14:26

在 Eclipse 中执行此操作时,取消选中“解决工作区工件”消除了错误,并且我可以成功执行全新安装。

While doing this in eclipse, unchecking the "Resolve workspace artifacts" got rid of the error, and I could do a clean install successfully.

关于从前 2024-10-16 14:14:26

检查您的 pom 中是否使用 eclipse 生命周期映射,如果是,请检查插件版本。对我来说,它是 maven-dependency-plugin 2.1 (有缺陷),而不是命令行 maven 使用的 2.0。

    <pluginManagement>
        <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings 
                only. It has no influence on the Maven build itself. -->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        org.apache.maven.plugins
                                    </groupId>
                                    <artifactId>
                                        maven-dependency-plugin
                                    </artifactId>
                                    <versionRange>
                                        [2.0,2.0.8) <!-- 2.1 fails the build due to the http://jira.codehaus.org/browse/MDEP-187 -->
                                    </versionRange>
                                    <goals>
                                        <goal>
                                            copy-dependencies
                                        </goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <execute/>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>

Check if you are using eclipse lifecycle mapping in your pom and if so, check the plugin version. For me, it was maven-dependency-plugin 2.1 (buggy) instead of 2.0 used by command line maven.

    <pluginManagement>
        <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings 
                only. It has no influence on the Maven build itself. -->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        org.apache.maven.plugins
                                    </groupId>
                                    <artifactId>
                                        maven-dependency-plugin
                                    </artifactId>
                                    <versionRange>
                                        [2.0,2.0.8) <!-- 2.1 fails the build due to the http://jira.codehaus.org/browse/MDEP-187 -->
                                    </versionRange>
                                    <goals>
                                        <goal>
                                            copy-dependencies
                                        </goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <execute/>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文