maven-pmd-plugin icon indicating copy to clipboard operation
maven-pmd-plugin copied to clipboard

Generate pmd.xml, but skip HTML generation

Open DamianFekete opened this issue 7 months ago • 10 comments
trafficstars

New feature, improvement proposal

I would like an option to keep generating the XML file, but to skip the HTML reports.

The pmd.xml file is used by Sonar so we don't need the HTML reports in this case.

I've searched on the Internet and looked at the code, but I don't think it's currently possible to skip the Doxia HTML generation.

I guess this is a similar question/request: https://stackoverflow.com/questions/42693443/why-maven-pmd-plugin-generate-pmd-html

DamianFekete avatar Apr 15 '25 13:04 DamianFekete

Mojo classes should be refactored, currently we have, like:

@Mojo(name = "check", defaultPhase = LifecyclePhase.VERIFY, threadSafe = true)
@Execute(goal = "pmd")
public class PmdViolationCheckMojo extends AbstractPmdViolationCheckMojo<Violation> {

Additional mojo execution @Execute(goal = "pmd") shuld be removed and Mojo should directly use org.apache.maven.plugins.pmd.exec.PmdExecutor

slawekjaranowski avatar May 18 '25 09:05 slawekjaranowski

I need this too! I just ran into this problem yesterday and can't figure out any way to configure the pmd-maven-plugin to only generate the XML findings file, but NOT the HTML report. I just reported the same issue for the spotbugs-maven-plugin: https://github.com/spotbugs/spotbugs-maven-plugin/discussions/1055

davewichers avatar May 22 '25 14:05 davewichers

I had similar problem: https://issues.apache.org/jira/browse/MPMD-403 (for different reason but I wanted similar outcome).

https://issues.apache.org/jira/browse/MPMD-403?focusedCommentId=17880071&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17880071:

For completeness - with :pmd being reporting plugin, and with no goal (that I could find) to do non-reporting analysis to produce pmd.xml only, with reporting context (and checking for skin) being prepared early, I'm able to work around my original problem, by configuring doxia to use other than html format (and not fail for project with not updated site.xml).

And I tried to introduce

  • https://github.com/apache/maven-doxia/pull/227

which then seemed for me easier than

Mojo classes should be refactored.

After all - I'd like to see Generate pmd.xml, but skip HTML generation as well!

pzygielo avatar May 22 '25 14:05 pzygielo

I would like to try a refactor, simply check is not a report goal ... so we should not call a report by directly PmdExecutor where is needed.

slawekjaranowski avatar May 22 '25 17:05 slawekjaranowski

Haha talked with @khmarbaise about this confusing situation too at work.

Please do it for both pmd and cpd goals and try to avoid the need the fork, so generating the xml-report (to be consumed by other tools) during build lifecycle.

Bukama avatar May 22 '25 19:05 Bukama

Firs step of refactor:

  • #206

Will be easier use executors in reports and mojos

slawekjaranowski avatar May 22 '25 20:05 slawekjaranowski

next step of refactor:

  • #210

slawekjaranowski avatar May 29 '25 21:05 slawekjaranowski

FYI: I found another reason, why we should not fork a lifecycle (pmd:check forking lifecycle to call pmd:pmd) - a customer has some maven projects with big dependency graphs (lots of dependencies, mostly snapshots), and it takes a couple of minutes to resolve the dependencies of the project. These couple of minutes are doubled, because it seems that for the forked lifecycle, maven needs to resolve the dependencies again for pmd:pmd... Removing this fork at least would reduce the build times for such projects when using pmd.

adangel avatar Jul 17 '25 13:07 adangel

@slawekjaranowski - 4 months have gone by, Any more progress on this?

davewichers avatar Aug 29 '25 13:08 davewichers

@davewichers I did first refactor in

  • #206

Now we can move code from CpdReport / PmdReport into corresponding CpdServiceExecutor / PmdServiceExecutor and finally use it in both report and check mojos.

simply my voluntarily time is limited - I hope work can be continued by others, especially if you need it

so question is why nobody didn't try to resolve it?

slawekjaranowski avatar Oct 07 '25 15:10 slawekjaranowski