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>
...
我通过命令成功使用了它
I use it successfully with the command
mvn install
但是,当我尝试将其包含在"pluginManagement"标记中时,启动install
目标时maven-dependency-plugin
会停止工作.
为什么"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文档:
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屋!