From 4f392c9d255950187eb5022fd80f8a44fe2645d4 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 21 Mar 2020 12:12:24 +0100 Subject: [PATCH] [doc] maven - add "Choosing the plugin version" --- docs/pages/pmd/userdocs/tools/maven.md | 57 +++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/docs/pages/pmd/userdocs/tools/maven.md b/docs/pages/pmd/userdocs/tools/maven.md index 267c0fc429..0a1d45691b 100644 --- a/docs/pages/pmd/userdocs/tools/maven.md +++ b/docs/pages/pmd/userdocs/tools/maven.md @@ -2,7 +2,8 @@ title: Maven PMD Plugin tags: [userdocs, tools] permalink: pmd_userdocs_tools_maven.html -last_updated: August 2017 +last_updated: March 2020 +mpmd_version: 3.13.0 author: > Miguel Griffa , Romain PELISSE , @@ -13,6 +14,36 @@ author: > ### Running the pmd plugin +#### Choosing the plugin version + +When adding the maven-pmd-plugin to your pom.xml, you need to select a version. To figure out the +latest available version, have a look at the official [maven-pmd-plugin documentation](https://maven.apache.org/plugins/maven-pmd-plugin/). + +As of {{ page.last_updated }}, the current plugin version is **{{ page.mpmd_version }}**. + +The version of the plugin should be specified in `` and if using the project +report additionally in `` elements. Here's an example for the pluginManagement +section: + +```xml + + + + + org.apache.maven.plugins + maven-pmd-plugin + {{ page.mpmd_version }} + + + + +``` + +When defining the version in the pluginManagment section, then it doesn't need to be specified in the normal plugins +section. However, it should additionally be specified in the reporting section. + +More information, see [Guide to Configuring Plugin-ins](https://maven.apache.org/guides/mini/guide-configuring-plugins.html). + #### Generating a project report To include the PMD report in the project reports section add the following lines under @@ -26,6 +57,7 @@ the reports element in your pom.xml: org.apache.maven.plugins maven-pmd-plugin + {{ page.mpmd_version }} @@ -58,9 +90,11 @@ PMD finds some violations. Therefore the `check` goal is used: org.apache.maven.plugins maven-pmd-plugin - 3.8 + {{ page.mpmd_version }} - true + + true + true @@ -88,11 +122,13 @@ you add `cpd-check` as a goal. To specify a ruleset, simply edit the previous configuration: +``` xml org.apache.maven.plugins maven-pmd-plugin + {{ page.mpmd_version }} /rulesets/java/braces.xml @@ -104,6 +140,7 @@ To specify a ruleset, simply edit the previous configuration: +``` The value of the 'ruleset' element can either be a relative address, an absolute address or even an url. @@ -119,23 +156,30 @@ will be able to resolve those other ruleset references. When using the Maven PMD plugin 3.8 or later along with PMD 5.6.0 or later, you can enable incremental analysis to speed up PMD's execution while retaining the quality of the analysis. You can additionally customize where the cache is stored:: +```xml org.apache.maven.plugins maven-pmd-plugin + {{ page.mpmd_version }} - true - ${project.build.directory}/pmd/pmd.cache + + true + + ${project.build.directory}/pmd/pmd.cache +``` #### Other configurations The Maven PMD plugin allows you to configure CPD, targetJDK, and the use of XRef to link the report to html source files, and the file encoding: +```xml org.apache.maven.plugins maven-pmd-plugin + {{ page.mpmd_version }} true ISO-8859-1 @@ -143,6 +187,7 @@ the report to html source files, and the file encoding: 1.4 +``` #### Upgrading the PMD version at runtime @@ -164,7 +209,7 @@ Maven plugin will use and benefit from the latest bugfixes and enhancements: org.apache.maven.plugins maven-pmd-plugin - 3.8 + {{ page.mpmd_version }} net.sourceforge.pmd