SonarQube扫描仪:使用非默认Java [英] SonarQube scanner: use non-default Java

查看:682
本文介绍了SonarQube扫描仪:使用非默认Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行SonarQube扫描仪的盒子.默认的JDK是7.

我需要使用JDK 8运行sonar-runner,但我想将默认的JDK保持在7.

我尝试在运行sonar-runner之前更改JAVA_HOME,但是没有运气.我也找不到任何可以改变它的属性.

有什么想法吗?

解决方案

设置 JAVA_HOME 应该有效(请参阅 sonar-scanner 用于Jenkins的SonarQube扫描器具有内置选项,可让您选择扫描仪应使用的JDK.

I have a box running SonarQube scanner. The default JDK is 7.

I need to run sonar-runner using JDK 8 but I would like to keep the default JDK at 7.

I tried changing JAVA_HOME before running sonar-runner but had no luck. I also couldn't find any properties that can change that.

Any thoughts?

解决方案

Setting JAVA_HOME should work (see sonar-scanner source code if you're curious).

It's behaving well for me with SonarQube Scanner 2.6.1. Default on Java 7:

nico@deb-nico:~$ sonar-scanner 
INFO: Scanner configuration file: /home/nico/sq_playground/sonar-scanner-2.6.1/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 2.6.1
INFO: Java 1.7.0_101 Oracle Corporation (64-bit)

Forcing to Java 8:

nico@deb-nico:~$ export JAVA_HOME=/usr/lib/jvm/java-8-oracle/jre
nico@deb-nico:~$ sonar-scanner 
INFO: Scanner configuration file: /home/nico/sq_playground/sonar-scanner-2.6.1/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 2.6.1
INFO: Java 1.8.0_91 Oracle Corporation (64-bit)

Looking good. Note that the SonarQube Scanner for Jenkins has a built-in option to let you choose which JDK the scanner should use.

这篇关于SonarQube扫描仪:使用非默认Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆