Joining the discussion on JDK 11 here.
I’m scanning a multi-module Android app that is not ready to be built with JDK 11. It currently builds and runs sonarqube using JDK 8 and Gradle.
Since I’m using the Java plugin there is a built-in dependency on “test” task for sonarqube task.
Its not possible to use sonarqube.dependsOn("test").remove()
since removal of a dependent task on a task instance is not allowed.
My only solution so far is to run JUnit tests and JaCoCo and then run sonarqube with -x, passing all the dependent tasks that I want skipped and also pass the -Dorg.gradle.java.home
argument pointing to JDK 11. An initial test run of this solution seems to “work” but I am not sure what other tasks will need to be skipped or even if this is valid.
Here is some example code where “$module” is any module in a multimodule Android project in Android Studio:
// Run jacocoTestReport which runs JUnit tests and outputs the JaCoCo XML file
sh "./gradlew $module:clean $module:jacocoTestReport"
// Now run sonarqube with JDK 11 and skip the dependent tasks leaving it just to read the JaCoCo XML file
sh """
./gradlew -Dorg.gradle.java.home=$jdk11 $module:sonarqube \
-x test \
-x compileJava \
-x compileTestJava \
-x testDebugUnitTest \
-x testDevelopmentDebugUnitTest \