Could not resolve all files for configuration ':condor:compileClasspath'

Objective: We are trying to switch to using Java 11 from Java 8. But the Jenkins pipeline fails to build.

sonarqube ver 3.0
Run the gradlew build before running the gradlew sonarqube

This is the command we are running:

CI=true ./gradlew sonarqube -Dsonar.login=${SONAR_LOGIN}${SONAR_URL} -x test -x compileJava -x compileTestJava -x compileScala -x compileTestScala -x compileKotlin -x compileTestKotlin -Dsonar.pullrequest.key=xx -Dsonar.pullrequest.branch=pr-new -Dsonar.pullrequest.base=master -Dsonar.pullrequest.provider=GitHub

When running this command, we see the error in the log:

* What went wrong:

Execution failed for task ':sonarqube'.
> Could not resolve all files for configuration ':condor:compileClasspath'.
   > Could not resolve project :segment_db.
     Required by:
         project :condor
      > Unable to find a matching variant of project :test_db:
          - Variant 'apiElements' capability com.test_db:1.0-SNAPSHOT:
              - Incompatible attribute:
                  - Required org.gradle.jvm.version '8' and found incompatible value '11'.

              - Other attributes:
                  - Found org.gradle.category 'library' but wasn't required.
                  - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
                  - Required org.gradle.usage 'java-api' and found compatible value 'java-api-jars'.
                  - Required org.jetbrains.kotlin.platform.type 'jvm' but no value provided.


Problem: If we are skipping the test, compile etc, shouldn’t it not throw this error:
Could not resolve all files for configuration ‘:condor:compileClasspath’.

The temporary fix is: we added
-Dsonar.scanner.force-deprecated-java-version-grace-period=true this to the above command and the build passes. However, once you deprecate support for Java 8, will this still work?

Please let me know if there is a workaround for this.
Any help will be greatly appreciated.

Hello @knitin ,

The compilation step is required for the analysis. If your build requires Java 8 then we recommend the following process:

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

This will build your project with Java 8 and run the analysis with Java 11. You can find more information for the migration in our documentation.

Thanks @Martin_Bednorz - We were able to identify the root cause of our issue. We had some references to Source & Target compatibility to java 8 version. That fixed the issue for us. We were already doing the solutions mentioned in the documentation.


1 Like

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