Maven 2 maven依赖插件:复制尝试复制类

Maven 2 maven依赖插件:复制尝试复制类,maven-2,maven,maven-plugin,maven-dependency-plugin,Maven 2,Maven,Maven Plugin,Maven Dependency Plugin,我有父pom和两个模块pom。在第一个模块中,我想将第二个模块(jar)复制到某个文件夹中。当我从第一个模块pom编译项目时,它可以工作,但当我试图从父项目pom编译时,插件尝试复制模块类而不是jar: [错误]无法执行目标 插件:maven依赖插件:2.1:复制 (默认)在项目模块1上: 从复制项目时出错 /home/chardex/projects/test/module2/target/Class 到 /home/chardex/projects/test/module1/target/l

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

[错误]无法执行目标 插件:maven依赖插件:2.1:复制 (默认)在项目模块1上: 从复制项目时出错 /home/chardex/projects/test/module2/target/Class 到 /home/chardex/projects/test/module1/target/lib/classes: /home/chardex/projects/test/module2/target/Class (是一个目录)->[Help 1]


org.apache.maven.plugins
maven依赖插件
编译
复制
...
模2
...
罐子

谢谢。

我相信这是maven依赖插件中的一个错误:

检查您是否在pom中使用eclipse生命周期映射,如果是,请检查插件版本。对我来说,它是maven依赖插件2.1(buggy),而不是命令行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>

org.eclipse.m2e
生命周期映射
1.0.0
org.apache.maven.plugins
maven依赖插件
[2.0,2.0.8) 
复制依赖项

在eclipse中执行此操作时,取消选中“Resolve workspace artifacts”(解析工作区工件)可以消除错误,我可以成功地完成一个干净的安装。

您是否从eclipse运行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>