Sonar-maven-plugin does not use maven.compiler.release

I have a maven-project, that is build with openjdk-11 and configures the source- and target-version only through the property maven.compiler.release.

Then I got the following error

Caused by: net.sourceforge.pmd.lang.java.ast.ParseException: Line 13, Column 88: Cannot use the diamond generic notation when running in JDK inferior to 1.7 mode!

The problem is that the sonar-maven-plugin only uses maven.compiler.source and maven.compiler.target and then falls back to java version 1.6 as the following outputs show

[INFO] Sensor JavaSquidSensor [java]
[INFO] Configured Java source version (sonar.java.source): 6
[INFO] JavaClasspath initialization
[INFO] JavaClasspath initialization (done) | time=1ms
[INFO] JavaTestClasspath initialization
[INFO] JavaTestClasspath initialization (done) | time=2ms
[INFO] Java Main Files AST scan
[INFO] 722 source files to be analyzed
```[INFO] Sensor JavaSquidSensor [java]
[INFO] Configured Java source version (sonar.java.source): 6
[INFO] JavaClasspath initialization
[INFO] JavaClasspath initialization (done) | time=1ms
[INFO] JavaTestClasspath initialization
[INFO] JavaTestClasspath initialization (done) | time=2ms
[INFO] Java Main Files AST scan
[INFO] 722 source files to be analyzed

Hey there.

This tells me you have an error not with SonarQube, but with PMD – do you have the community-supportted jensgerdes/sonar-pmd plugin installed on your SonarQube instance?

What do you expect the value to be (what’s your target version)? Is it possible that sonar.java.source is being forced anywhere (a pom.xml file or build configuration?)

Yes, we have installed this plugin in version 3.2.1, which supports java 11 regarding to https://github.com/jensgerdes/sonar-pmd

I expect it to be java version 1.8 oder 8, because my maven-project sets

<maven.compiler.release>8</maven.compiler.release>

sonar.java.source was not set manually.

You should report the error to the plugin maintainer in that case. While we’re friends, we don’t support that plugin in this community. :slight_smile:

Ah. Got it. maven.compiler.release won’t do it, but maven.compiler.source and maven.compiler.taraget will.

1. <project>
2. [...]
3. <properties>
4. <maven.compiler.source>1.8</maven.compiler.source>
5. <maven.compiler.target>1.8</maven.compiler.target>
6. </properties>
7. [...]
8. </project>

Some reading tells me that maybe we should consider maven.compiler.release, but I’m not 100% sure. I’ll ping around.

The error is already known. Here is the link for other users, looking for the same error:

Thanks!