SonarQube Java Warning in Azure DevOps Gradle Task

  • ALM used
    BitBucket Cloud
  • CI system used
    Azure DevOps
  • Languages of the repository
  • Error observed
> Task :sonarqube
The version of Java ( you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.

We are using the Azure DevOps Gradle task. The sonarqube task is embedded in task.
Our Java code is still using Java 11, is there a way for us to have the “sonarqube” task use Java 17?

DevOps Gradle Task

task: Gradle@2
    displayName: Gradle Build
      gradleWrapperFile: 'gradlew'
      tasks: 'clean build publish'
      publishJUnitResults: true
      testResultsFiles: '**/TEST-*.xml'
      javaHomeOption: 'JDKVersion'
      jdkVersionOption: '1.11'
      sonarQubeRunAnalysis: true
      sqGradlePluginVersionChoice: 'specify'
      sonarQubeGradlePluginVersion: '3.3'
      spotBugsAnalysis: false


It seems like you’re asking how you can compile your code to Java 11 while using Java 17 to analyze? Go ahead and switch your Java version to 17, and target Java 11 in your compile, like so.


Tried setting up build.gradle with

compileJava   {
  sourceCompatibility = '17'
  targetCompatibility = '11'

Gradle throws an exception when trying to do that.

Caused by: java.lang.IllegalStateException: warning: source release 17 requires target release 17

Any updates on this warning ?