Sonar Maven Plugin and Java 21

Hi !
My company uses SonarQube and when we do builds we do sonar analysis through maven plugin.
We need to upgrade our builds to Java21 and I upgraded sonar plugin to latest version - org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121, but even with that when we run it, there is exception with PMD (which we don’t reference directly):

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar (default-cli) on project xyz-e2etest: Unsupported Java version for PMD: 21 → [Help 1]

Few lines before I can see identification:

[INFO] 14:12:24.070 Sensor JavaSensor [java] (done) | time=4019ms
[INFO] 14:12:24.070 Sensor PmdSensor [pmd]
[INFO] 14:12:24.072 Execute PMD 6.45.0
[INFO] 14:12:24.083 Execute PMD 6.45.0 (done) | time=11ms

Is there a new version of plugin available, or is there a way to use different PMD that supports Java21?

Any help (workaround) would be appreciated.
Andy

Seems you’re using this community plugin

in version 3.4.0 shipping with PMD 6.45.0
see GitHub - jborgers/sonar-pmd: ☕️ PMD Plugin for SonarQube

According to the table the planned version 4.0.0 of the plugin ships with PMD 7.2.0 which supports already Java 22 .

You should also reconsider whether it is really still necessary to use PMD !?

1 Like