xvik / gradle-quality-plugin

Gradle quality plugin for Java and Groovy
http://xvik.github.io/gradle-quality-plugin
MIT License
134 stars 11 forks source link

Add an ability to configure or disable pmd build cache #10

Closed baev closed 5 years ago

baev commented 6 years ago
This analysis could be faster, please consider using Incremental Analysis: https://pmd.github.io/pmd-6.6.0/pmd_userdocs_incremental_analysis.html

Pmd has an option -no-cache that disables build cache, but as far as I know there is no way to specify it via gradle-pmd-plugin as well as no way to configure cache dir.

Related issues: https://github.com/gradle/gradle/issues/2862 https://github.com/gradle/gradle/pull/3125

PS don't know why but I'm getting hundreds of lines with such warning per module

DaddyMoe commented 6 years ago

+1

xvik commented 6 years ago

I can't do anything with it, sorry. We can only wait for an official fix (return of the reverted pmd dsl extension).

PS don't know why but I'm getting hundreds of lines with such warning per module

This is odd: you should see only one message per module. Can't imagine any case when this could happen. If you have some simple project with such behaviour please share with me and I will look.

baev commented 6 years ago

If you have some simple project with such behaviour please share with me and I will look.

https://github.com/baev/gradle-quality-plugin-issue10

xvik commented 6 years ago

Thank you for the sample project! The issue indeed exists, but it's again related to pmd.. almost :)

By default, when we have single source dir (src/main/java) it's passed as dir to pmd ant task and so we see just one warning. If we add another directory (like generated dir in your case) then gradle will set sources into ant task as separate files. Now the interesting part, pmd ant task is called just once, but internally it runs pmd for each source file and, of course, show the warning each time.

I could look to regroup FileTree (to make conversion from gradle FileTree into ant FileSet smarter), but it will become completely useless as soon as gradle introduce new pmd flag and hide warnings... so I think it's better to simply wait for a new flag

eatdrinksleepcode commented 6 years ago

@xvik so adding an addtionalArguments or similar property to allow me to pass arbitrary command line arguments to PMD is not an option? This is a familiar pattern that many tools use when wrapping other tools, precisely to allow users flexibility to deal with mismatches between the two tools.

xvik commented 6 years ago

@eatdrinksleepcode If it was my implementation (like animalsniffer plugin) I would already fix that. But I'm using gradle's pmd plugin and there is simply no way to modify ant task call. All we have is an official extension for pmd plugin configuration and so we have to wait when gradle team add new option there.

psdmca commented 5 years ago

+1

jjathman commented 5 years ago

It looks like the latest Gradle release (5.6) has support for PMD incremental analysis now. Is this possible to fix now?

https://docs.gradle.org/current/release-notes.html#support-for-pmd-incremental-analysis

xvik commented 5 years ago

Great, thank you! That means that everyone could remove this warning even now by applying pmd configuration directly.

In the next version, I will mirror this configuration as quality.enablePmdIncrementalAnalysis (or something like this) to simplify configuration.

I don't think that this option should be enabled by default. I assume there might be issues with gradle's own incremental compilation (which was the reson why initial support was rolled back). But if anyone could assure that it is safe to enable it by default please tell me.

xvik commented 5 years ago

Finally have time to look at it. The original issue (pmd warnings) was completely solved by new pmd plugin version: gradle now applies explicit -nocache parameter when incremental compilation is not enabled and so warning should never appear anymore (no matter if incremental support enabled or not).

As promised, I only added new pmd configuration shortcut in quality closure:

quality {
   pmdIncremental = true
}

Disabled by default.