I am trying to configure the Maven Checkstyle Plugin for reporting and would like to change the Checkstyle dependency to 7.5 instead of the standard 6.11.2.
To achieve this, I declare a pluginManagementdependency in the parent pom. In a child project, I just reference the plugin in the reporting tag.
However, I see that by default Checkstyle (6.11.2) loads into the repository. Please see below parent and child care.
<?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>
Baby 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>
Can you help if this is the right way to override dependency for a reporting plugin? If so, why is it not working?
Maven Version: 3.2.5
Santo source
share