java - Maven的pom.xml中的pluginManagement是什么?

标签 java maven build pom.xml maven-dependency-plugin

这是我的 pom 文件的片段。

....
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.4</version>                        
                <executions>
                    <execution>
                        <phase>install</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            ......
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
...

我通过命令成功使用它

mvn install

但是,当我尝试将其包含到“pluginManagement”标记中时,当我启动 install 目标时,maven-dependency-plugin 停止工作。 为什么“pluginManagement”标签会改变构建行为?或者我应该使用另一个目标或选择?

最佳答案

您还需要添加

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
    </plugin>
</plugins>

在您的构建中,因为 pluginManagement 只是在所有项目模块之间共享相同插件配置的一种方式。

来自 Maven 文档:

pluginManagement: is an element that is seen along side plugins. Plugin Management contains plugin elements in much the same way, except that rather than configuring plugin information for this particular project build, it is intended to configure project builds that inherit from this one. However, this only configures plugins that are actually referenced within the plugins element in the children. The children have every right to override pluginManagement definitions.

关于java - Maven的pom.xml中的pluginManagement是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40159872/

相关文章:

linux - 在 Jenkins 上构建的差异?

java - Spring MVC 基于 Java 的配置 - JSP 无法解析

node.js - Gulp.src 不考虑基目录

c++ - Makefile 有两次看不到 main.o

java - maven-dependency-plugin 是否使用其他类型的工件解析而不是 maven 的其余部分?

java - 我可以获得maven执行的测试用例总数吗?

java - Android studio如何引用库?

java - 如何在redhat中安装maven 2.2.1?

java - hadoop中的分区文件是如何创建的

java - 元素未添加到数组列表中