Getting issues for multiple Java versions

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    • SonarQube 10.3 for Java. The analysis is run via the sonar-maven-plugin’s sonar:sonar goal. We have the extra encumberement that we use Maven Tycho, not regular Maven
  • how is SonarQube deployed: zip, Docker, Helm
    • Docker
  • what are you trying to achieve
    • Our production code is written for Java 11 while the test code is in Java 17. Both of these are part of the same SonarQube project. We run and compile our product, tests, and sonarqube with Java 17 (JustJ/Temurin). I would now like to receive Java 17 issues/code smells… for the test code, while not receiving them for the production code.
  • what have you tried so far to achieve this
    • We’ve been using -Dsonar.java.source=11 -Dsonar.java.target=11 since forever when running our sonar analysis. Removing it, or making it 17 instead of 11 gave me a bunch of Java 17 code smells on the Java 11 production code

Hey there.

You should be able to set this at a module level in the pom.xml of your product code.

<properties>
<sonar.java.source>11</sonar.java.source>
</properties>