algiogia
algiogia

Reputation: 955

SonarQube Java version used to verify code

How can I know against which version of Java SonarQube validates the code? Is it the version of the JVM? What then if my project is based on a different version?

Upvotes: 8

Views: 34202

Answers (4)

Suresh
Suresh

Reputation: 1601

From Sonarqube documentation, this is what I found the version of sonarqube that supports java 1.8

enter image description here

Sonarqube 7.7 is the latest version that supports Java 1.8.

Please tick my answer if this is the information you are looking for..

enter image description here

Upvotes: 0

vsingh
vsingh

Reputation: 6759

From SonarCube 8.3 docs

When using SonarScanner to perform analyses of project, the property sonar.java.source can to be set manually in sonar-project.properties. Accepted formats are:

"1.X" (for instance 1.6 for java 6, 1.7 for java 7, 1.8 for java 8, etc.) "X" (for instance 7 for java 7, 8 for java 8, etc. )

https://docs.sonarqube.org/latest/analysis/languages/java/

In our project, we use jdk 11. We have not set anything explicitly and it reads from pom.xml.

When running on the jenkins, I can see the output

[INFO] Configured Java source version (sonar.java.source): 11

Upvotes: 0

I do confirm that this property sonar.java.source is used only by the PMD tool. The SonarSource's Java analyser uses a superset grammar and so can analyse source files regardless of the Java version they comply to.

Upvotes: 2

Eduardo Briguenti Vieira
Eduardo Briguenti Vieira

Reputation: 4579

The default value is 1.5.

To set the appropriate version, you need to set sonar.java.source property to tell PMD which version of Java your source code complies to.

Possible values: 1.4, 1.5 or 5, 1.6 or 6, 1.7 or 7. Since version 2.2 of the plugin, this property can also be set to 1.8 or 8.

If you're using the ant task, just add:

 <property name="sonar.java.source" value="${javaversion}"/> 

If you're using the SonarRunner, just add the line below to the file <install_directory>/conf/sonar-runner.properties:

sonar.java.source=1.5

Upvotes: 10

Related Questions