我的 Maven 项目给了我像这样的 reports.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对插件版本更严格,必须指定插件版本。我在 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>