报告期间未考虑在 pluginManagement 中添加的依赖项
Dependencies added in pluginManagement not considered during reporting
我正在尝试配置用于报告的 Maven Checkstyle 插件,并希望将 Checkstyle 的依赖项更改为 7.5 而不是默认的 6.11.2。
为了实现这一点,我在 parent pom 中声明了 pluginManagement
和依赖项。
在 child 项目中,我只是在报告标记中引用插件。
但是我看到默认的 Checkstyle (6.11.2) 正在下载到存储库中。请参阅下面的 parent 和 child pom.
<?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.mycompany.app</groupId>
<artifactId>parent_app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>parent_app</name>
<modules>
<module>my-app2</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>7.5</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Child pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mycompany.app</groupId>
<artifactId>parent_app</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app2</artifactId>
<version>1.0-SNAPSHOT</version>
<name>my-app2</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<reporting>
<plugins>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>src/main/resources/checkstyle.xml</configLocation>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
</project>
如果这是覆盖报告插件依赖性的正确方法,您能帮忙吗?如果是这样,为什么它不起作用?
Maven 版本:3.2.5
Maven 站点插件似乎存在错误(MSITE-507 后引入的回归)。显式添加到构建中配置的托管插件的依赖项确实没有被考虑在内,除非插件也声明了自己。也就是说,父 POM 中的以下内容将为您提供所需的行为(使用 Maven 3.3.9 测试):
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>7.5</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
</plugins>
</build>
当在本地存储库中安装新的父级并启动子级的构建(例如 mvn clean site
)时,将使用预期的 Checkstyle 7.5。
我正在尝试配置用于报告的 Maven Checkstyle 插件,并希望将 Checkstyle 的依赖项更改为 7.5 而不是默认的 6.11.2。
为了实现这一点,我在 parent pom 中声明了 pluginManagement
和依赖项。
在 child 项目中,我只是在报告标记中引用插件。
但是我看到默认的 Checkstyle (6.11.2) 正在下载到存储库中。请参阅下面的 parent 和 child pom.
<?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.mycompany.app</groupId>
<artifactId>parent_app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>parent_app</name>
<modules>
<module>my-app2</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>7.5</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Child pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mycompany.app</groupId>
<artifactId>parent_app</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app2</artifactId>
<version>1.0-SNAPSHOT</version>
<name>my-app2</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<reporting>
<plugins>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>src/main/resources/checkstyle.xml</configLocation>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
</project>
如果这是覆盖报告插件依赖性的正确方法,您能帮忙吗?如果是这样,为什么它不起作用?
Maven 版本:3.2.5
Maven 站点插件似乎存在错误(MSITE-507 后引入的回归)。显式添加到构建中配置的托管插件的依赖项确实没有被考虑在内,除非插件也声明了自己。也就是说,父 POM 中的以下内容将为您提供所需的行为(使用 Maven 3.3.9 测试):
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>7.5</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
</plugins>
</build>
当在本地存储库中安装新的父级并启动子级的构建(例如 mvn clean site
)时,将使用预期的 Checkstyle 7.5。