SonarQube Java version used to verify code

余生长醉 提交于 2019-12-19 07:10:12

问题


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?


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/24289704/sonarqube-java-version-used-to-verify-code

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!