PMD-Intellij icon indicating copy to clipboard operation
PMD-Intellij copied to clipboard

Add support for PMD 7 (and Java 21)

Open uhafner opened this issue 1 year ago • 10 comments

PMD 7 is now available and provides support for Java 21. It would be helpful if the PMD IntelliJ plugin would also support this new version.

uhafner avatar Mar 31 '24 15:03 uhafner

Agreed. A difficulty here is that PMD 7 is not backwards compatible, that is, custom rules written for PMD 6 will not work in PMD 7. Those rules will have to be migrated. It should still be possible to use the PMD6 custom rules for some time.

jborgers avatar Apr 03 '24 11:04 jborgers

Note that you can specify '20-preview' as Target JDK. All Java 21 syntax I tested was recognized this way.

jborgers avatar Apr 08 '24 09:04 jborgers

I would really appreciate to move to PMD 7. There is no PMD 7 plugin for intellij right now....

cree01 avatar Apr 12 '24 17:04 cree01

Is anyone looking into this, or should I make an attempt and see if I can get it working?

martenbohlin avatar Apr 20 '24 06:04 martenbohlin

Yes, please look into it and share your experiences here. Difficulty will be to still support PMD 6 custom rules since PMD 7 is not backwards compatible. This is now easier to test with the new plugin release by choosing the custom jpinpoint-rules from the drop down list.

Note that it is more clear now what java versions are supported. PMD 6 goes up to java 20-preview. Effectively it supports java 21, at least for what I have tested. If you find otherwise, please let me know here. So maybe that takes some pressure away from supporting PMD 7.

Op za 20 apr 2024 08:53 schreef Mårten Bohlin @.***>:

Is anyone looking into this, or should I make an attempt and see if I can get it working?

— Reply to this email directly, view it on GitHub https://github.com/amitdev/PMD-Intellij/issues/161#issuecomment-2067580644, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF3TVW2VCMCQD5VTQ3LMCFLY6IGB3AVCNFSM6AAAAABFQP36FSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRXGU4DANRUGQ . You are receiving this because you commented.Message ID: @.***>

jborgers avatar Apr 20 '24 08:04 jborgers

I think the best solution would be to release a new major version of the plugin that uses PMD 7. And if you want to continue to use PMD 6 you will need to pin the plugin to the current version of the plugin.

martenbohlin avatar Apr 20 '24 12:04 martenbohlin

We have about 120 rules which need to be migrated, which takes quite some time. I would not like for our users to automatically upgrade to the new plugin version and ending up without the possibility to use the rules, and being puzzled about why. So I'd like it to be very clear to the user that if (s)he chooses to upgrade, that the consequence is that the PMD 6 custom rules don't work anymore.

jborgers avatar Apr 20 '24 13:04 jborgers

I have made a PR for a upgrade to PMD 7 and it seems to works fine but needs more testing.

We have started to use the new improved rules that PMD7 offers, and for us it is an obstacle to not see all the rules in IntelliJ.
One solution would be to publish a PMD7 compatible plugin under a different name, but then I guess many users would miss that there is an upgraded version.

martenbohlin avatar Apr 21 '24 12:04 martenbohlin

Hi Marten,

I can help with some testing on Friday afternoon Amsterdam time zone.

jborgers avatar Apr 23 '24 12:04 jborgers

I was busy releasing sonar-pmd plugin and testing it. Somehow we need to validate if a custom rules set when loaded is of the correct version, if not, show a proper message what to do (revert to pmd6 version.)

jborgers avatar Apr 27 '24 13:04 jborgers

I didn't find a property on ruleset level which specifies the pmd version (6 or 7). A difference I see is in rule properties: <property name="version" value="2.0"/> is used for PMD 6. PMD 7 uses version 3.1 as default and the property is not to be specified.

jborgers avatar May 01 '24 09:05 jborgers

Sorry, I had a lot of other things to do lately, but now I have time for this again. Do you have a small java project publicly available that I can test on? We have not used any custom rules in our projects.

martenbohlin avatar May 11 '24 15:05 martenbohlin

See #172 and #173

jborgers avatar May 17 '24 14:05 jborgers

Tested OK in version 2.0.0

jborgers avatar May 27 '24 10:05 jborgers