Maven pluginManagement配置继承奇怪的行为

Vla*_*eev 7 inheritance build maven-plugin pom.xml maven

pluginManagement在我的父母中使用元素pom.xml为其所有子节点配置插件.例如,我有以下配置:

<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>
Run Code Online (Sandbox Code Playgroud)

官方文档指出pluginManagement仍然必须将配置的插件添加到plugins子poms中的元素中.事实上,如果我从孩子pom中删除它:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
</plugin>
Run Code Online (Sandbox Code Playgroud)

然后maven-dependency-plugininstall阶段停止射击.但是,似乎它不会影响其他一些插件,即maven-resource-plugin.即使我没有

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
</plugin>
Run Code Online (Sandbox Code Playgroud)

在我的孩子pom中,它的copy-resources目标仍然在install阶段激发并执行它配置的工作.

为什么会出现这种行为?是否有一个总是继承的插件列表,或者我可能遗漏了什么?

use*_*849 7

整个POM不可见; 但鉴于你所描述的行为,这是一个罐子,战争或耳朵,对吗?默认情况下,为这些打包类型定义资源插件.它包括复制资源的执行(如@maba所述).

由于插件定义包含在您的子POM中(即使您没有直接将其放在那里),Maven会将该<pluginManagement>部分中定义的执行与Maven提供的执行合并.

文档描述了打包类型的默认生命周期绑定.注意dependency没有提到插件; 但是resources; 这就是你观察差异的原因.运行with -X将显示插件执行.