SonarQube for different java versions

Hi Team,

we are using sonarqube which is installed on cloud premises with the following configuraitons:

sonarqube version: Version 7.9.4 (build 35981)
Java Code Quality and Security Code Analyzer for Java :6.3.2 (build 22818)
kotlin plugin: detekt: 2.3.0

now the question is we are having projects which uses java11 and one more project(Android) which uses Kotlin java8.

we are able to integrate with the projects using java11, however when we are trying to integrate with Kotlin project which uses java8, it is giving me the following error SonarScanner will require Java 11 to run starting in SonarQube 8.x.

Hi Nakka,

Welcome to the Community!

So, as stated in the documentation:

SonarQube is able to analyze any kind of Java source files regardless of the version of Java they comply to.

To achieve this, for a project not on Java 11, you could do as follows:

  1. In your build pipeline, set JAVA_HOME to your Java 8 installation
  2. Build the Kotlin project
  3. Change JAVA_HOME to point to the Java 11 installation
  4. Launch SonarScanner

Best regards,

HI @Daniel_Meppiel,

Thanks for the fast reply.

we are using jenkins as CI tool and gradle to build the projects and sonar server is running somewhere in the cloud and we use to gradle task to perform the sonarscanning operation

we are building the kotlin project in java 8 only, when you say change the JAVA_HOME to java11 and launch SonarScanner, do you mean to say change the java version to 11 and run the gradle task?

you are reply is highly appreciated

Hi @Nakka,

The general process above will need to be applied within your Gradle logic.
This falls into the Gradle configuration domain. Depending how you have defined your gradle tasks, this could be something like:

export JAVA_HOME=/path/to/java8
gradle build ...
export JAVA_HOME=/path/to/java11
gradle sonarqube ...

Hi @Daniel_Meppiel,

Thanks for suggestion, I’ll surely try your suggestion and get back to you

HI @Daniel_Meppiel,

I followed your suggestion and got the following error:

ProguardR8DictionaryGenerator: neither proguard tasks, nor R8 tasks were not found

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ‘:app’.

kotlin.KotlinNullPointerException (no error message)

Please help me with the needful

Hi @Nakka, you will need to dig into your Gradle logic specifics. This is beyond SonarQube scope and I cannot help you further.