Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

To show PMD warnings analysis results, print the PMD XML needs to put out to the build log.

...

Table of Contents
minLevel1
maxLevel7

Using PMD Command Line

Use For the PMD CLI, use the --format xml flag to print out the PMD analysis into the build log. For example:

Code Block
run.sh pmd --dir $PWD/src/main --rulesets category/java/bestpractices.xml --format xml

...

Using Maven PMD

The Maven PMD plugin, doesn’t support printing the XML into the logs. Instead print the generated target/pmd.xml file into the build log by a follow up final task:

Code Block
#!/bin/bash
cat ./target/pmd.xml || echo "No PMD analytics generated"

...

...

Using Gradle PMD

The Gradle PMD plugin, doesn’t support printing the XML into the logs. Instead print the generated ./build/reports/pmd/main.xml file into the build log by a follow up final task:

Code Block
#!/bin/bash
cat ./build/reports/pmd/main.xml || echo "No PMD analytics generated"

...

Using PMD via other Build System

Typically the build system tool generate a PMD report xml, and you can dump . Dump that to the console by a final task. For example:

Code Block
#!/bin/bash
cat ./a-build-dir/pmd.xml || echo "No PMD analytics generated"

...