@Margarita_Nedzelska
Wow, it was a long journey but finally, seems like the problem is solved. Thank you so much for your patience. The less obvious part here is we had to set sonar.java.jdkHome
property at a module level, not in the root project (we can also set it here too, but it isn’t required).
Another thing that is not covered in the highlighted topics and out of my question is how to make everything work not only in one specific machine.
Let me share the final solution to help everyone who will search for the same answers to my question (I think it’s also nice to put these details someplace in the integration documentation because it isn’t possible to use sonar without this trick in any Android project that use Gradle 8+)
Pre requirements:
We have to install some tool that allows us to install and manage different Java versions. For instance it might be SDKMan, for GitHub it might be setup-java action.
Other tools are also applicable, 2 crucial requirements - possibility to install a few Java versions, and get the path to a specific one.
After we install the java management tool we have to put in the module build.gradle
file the following code:
sonarqube {
properties {
property "sonar.java.jdkHome", project.findProperty('jdk8Home')
}
}
You can choose any other name for jdk8Home
property, doesn’t matter.
Then, when we run sonar command, we have to use our java management tool api to get java 8 path and pass it to Gradle. For SDKMan it might look following:
./gradlew sonar -Pjdk8Home=`sdk home java 8.0.382-amzn`
The step above is necessary because Gradle 8+ requires running tasks in a Java 17 environment.
For everyone who is looking for working example, check it out in the GitHub