Maven 中 pluginManagement 的范围 & reporting.plugins.plugin.version 缺少警告

Scope of pluginManagement in Maven & reporting.plugins.plugin.version missing warning

我的 Maven 项目给我 reporting.plugins.plugin.version 如下警告:

[WARNING] Some problems were encountered while building the effective model for com.example:test:jar:1.0-SNAPSHOT
[WARNING] 'reporting.plugins.plugin.version' for org.jacoco:jacoco-maven-plugin is missing. @ line 10, column 21

我知道必须指定 Maven 3 is stricter about plugin versions 和插件版本。我在pluginManagement中指定了版本:

<pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.2.201409121644</version>
        </plugin>
    </plugins>
</pluginManagement>

当我在 build/plugins:

中使用插件时,这工作正常并且没有警告
<build>
    <plugins>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

不起作用,然而,在reporting/plugins:

<reporting>
    <plugins>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
        </plugin>
    </plugins>
</reporting>

我的问题是:build/plugingManagement中指定的版本范围是否仅限于<build>标签内?我可以在不在两个地方复制插件版本的情况下修复警告吗?


这是生成警告的完整示例:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>test</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
            </plugin>

        </plugins>
    </reporting>


    <build>
        <plugins>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
            </plugin>
        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.7.2.201409121644</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

这似乎是旧版 Maven 中的错误。在 apache 上查看 this bug ticket

。尝试使用 Maven 3 和 maven-site-plugin-3。