Maven 的 pom.xml 中的 pluginManagement 是什么? [英] What is pluginManagement in Maven's pom.xml?
问题描述
这是我的 pom 文件的片段.
This is a snippet of my pom file.
....
<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"标签中时,maven-dependency-plugin
在我启动 install
目标时停止工作.为什么pluginManagement"标签会改变构建行为?还是我应该使用其他目标或选项?
But, when I try to enclose it into the "pluginManagement" tag, the maven-dependency-plugin
stops working when I launch the install
goal.
Why does the "pluginManagement" tag change the build behavior? Or should I use another goal or option?
推荐答案
你还需要添加
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
</plugins>
在您的构建中,因为 pluginManagement
只是在所有项目模块中共享相同插件配置的一种方式.
in your build, because pluginManagement
is only a way to share the same plugin configuration across all your project modules.
来自 Maven 文档:
From Maven documentation:
pluginManagement:是一个与插件一起看到的元素.插件管理以几乎相同的方式包含插件元素,除了不是为此特定项目构建配置插件信息,而是旨在配置从该项目构建继承的项目构建.但是,这仅配置在子项的 plugins 元素中实际引用的插件.孩子们有权覆盖 pluginManagement 定义.
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.
这篇关于Maven 的 pom.xml 中的 pluginManagement 是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!