Search code examples
sonarqubepmd

Can't find PMD XML report


I run a Maven command as "mvn sonar:sonar pmd:pmd", I can see the generated pmd.xml file under target folder in each module. But in command output I can see

[INFO] Sensor Import of PMD issues [java]

[INFO] Importing D:\Temp\workshop\111\mat\mat-publish\mat-publish-core\target\pmd.xml

[ERROR] Can't find PMD XML report: D:\Temp\workshop\111\mat\mat-publish\mat-publish-core\target\pmd.xml

[INFO] Sensor Import of PMD issues [java] (done) | time=16ms

I can open the pmd.xml directly with the path, I am not sure why it report cannot find the file.


Solution

  • You execute goals in a wrong order:

    mvn sonar:sonar pmd:pmd
    

    SonarScanner is executed as first, and PMD as second. It means that PMD reports are unavailable when SonarScanner is doing its job. You have to change the order:

    mvn pmd:pmd sonar:sonar