【发布时间】:2012-09-23 06:57:49
【问题描述】:
我在父级pom.xml 中使用pluginManagement 元素为其所有子级配置插件。比如我有如下配置:
<pluginManagement>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<id>copy-artifacts</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>some/where/else</outputDirectory>
<resources>
<resource>
<directory>some/another/resource</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>deps/dir</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</pluginManagement>
官方文档指出,pluginManagement 中配置的插件仍然必须添加到子 pom 中的plugins 元素中。事实上,如果我从子 pom 中删除它:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
然后maven-dependency-plugin 在install 阶段停止发射。但是,它似乎不影响其他一些插件,即maven-resource-plugin。就算我没有
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
在我的子 pom 中,它的 copy-resources 目标仍然在 install 阶段触发并执行它配置的工作。
为什么会出现这种行为?是否有一个总是继承的插件列表,或者我可能遗漏了什么?
【问题讨论】:
-
看看有效的 pom 来分析你的问题(通过 mvn help:effective-pom)。
-
谢谢,完全忘记了。会看看。
标签: maven inheritance build maven-plugin pom.xml