Sonar Gradle plugin 3.1 does not resolve Java Toolchain path correctly

Versions:

  • Gradle 6.7.1 (same result with 6.8)
  • Sonar Gradle plugin 3.1
  • SonarCloud

Gradle configuration:

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(14)
    }
}

Running Sonar analysis on CI server results in:

Invalid value for 'sonar.java.jdkHome' property, defaulting to runtime JDK.	
Configured location does not exists: '/opt/bitnami/apps/jenkins/jenkins_home/workspace/ol-sandbox-test-pipeline_develop/Optional[/usr/lib/jvm/jdk-14.0.2+12]'	
Invalid value for 'sonar.java.jdkHome' property, defaulting to runtime JDK.	
Configured location does not exists: '/opt/bitnami/apps/jenkins/jenkins_home/workspace/ol-sandbox-test-pipeline_develop/Optional[/usr/lib/jvm/jdk-14.0.2+12]'	

Running on my machine results in similar output (log with --info):

> Task :sonarqube
0 files ignored because of scm ignore settings
Quality profile for java: Sonar way
------------- Run sensors on module sandbox-test-pipeline
JavaScript/TypeScript frontend is enabled
Load metrics repository
Load metrics repository (done) | time=49ms
Sensor JavaSquidSensor [java]
Configured Java source version (sonar.java.source): 14
JavaClasspath initialization
Invalid value for 'sonar.java.jdkHome' property, defaulting to runtime JDK.
Configured location does not exists: 'C:\Users\grimsa\.gradle\daemon\6.7.1\Optional[C:\Users\grimsa\.gradle\jdks\jdk-14.0.2+12]'
JavaClasspath initialization (done) | time=0ms
JavaTestClasspath initialization
Invalid value for 'sonar.java.jdkHome' property, defaulting to runtime JDK.
Configured location does not exists: 'C:\Users\grimsa\.gradle\daemon\6.7.1\Optional[C:\Users\grimsa\.gradle\jdks\jdk-14.0.2+12]'

It seems that JDK path should be used as-is, instead of being appended to some path prefix.

Maybe the cause is incomplete implementation of https://jira.sonarsource.com/browse/SONARGRADL-73 ?

1 Like

Hi,

I was able to reproduce, there is indeed a mistake in the implementation of SONARGRADL-73.

Here is a ticket you can follow:

Thanks for the feedback!

2 Likes

I have just release version 3.1.1 of the SonarScanner for Gradle to fix this issue.

I can confirm that we no longer see those messages in the logs after upgrading to 3.1.1.

Thanks!

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.