SonarQube - Gradle Build Fails with Submodule Dependency Resolution Error

I’m working on a Java & Spring project (ladm-adsvc ) with a build.gradle file that includes SonarQube configuration. This project has a submodule (ladm-commons ) registered within it.

When I run the ./gradlew sonar command, I encounter the following error:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':compileTestJava'.
> Could not resolve all task dependencies for configuration ':testCompileClasspath'.
   > Could not resolve project :ladm-commons.
     Required by:
         project :
      > No matching configuration of project :ladm-commons was found. The consumer was configured to find an API of a library compatible with Java 11, preferably in the form of class files, and its dependencies declared externally but:
          - None of the consumable configurations have attributes.

Here is my setting for project “ladm-adsvc” build.gradle

...

plugins {
    id 'org.sonarqube' version '3.5.0.2730'
}

allprojects { project ->
    apply plugin: 'org.sonarqube'
    sonar {
        properties {
            property "sonar.projectKey", determineSonarProjectKey(project.name)
            property "sonar.host.url", "https://sonar.linecorp.com"
            property "sonar.login", determineSonarLogin(project.name)
        }
    }
}


static def determineSonarProjectKey(String projectName) {
    switch (projectName) {
        case 'ladm-adsvc':
            return "ladm-da-dev-1"
        case 'ladm-commons':
            return "ladm-commons"
    }
}

static def determineSonarLogin(String projectName) {
    switch (projectName) {
        case 'ladm-adsvc':
            return "testsetsets"
        case 'ladm-commons':
            return "testetst"
    }
}

...

Both projects are set to use Java 11 (sourceCompatibility = 1.11). I’ve ensured that the submodule is initialized and updated, and I’ve checked that the settings.gradle includes the ladm-commons submodule. However, I’m still facing the issue.

I would appreciate any guidance on how to resolve this dependency resolution error.

Thank you in advance for your help!

Hi,

What’s your SonarQube version?

Speaking of versions, the current version of SonarScanner for Gradle is 4.4.1.3373, although upgrading to that version means you will need to analyze with Java 17. You can still build with or to Java 11, but you may want to add sonar.gradle.skipCompile=true to your properties. Otherwise, analysis will force (another) compilation.

Back to your error, does it happen during an extra compile forced by analysis? If so sonar.gradle.skipCompile (which is likely not available to your outdated scanner version) would likely fix that.

 
HTH,
Ann

Hello,
Thank you for your response!

We are using SonarQube version 9.9.2 (build 77730) and SonarScanner version 3.5.0.2730. Since we have set up a SonarQube Enterprise server, it’s not straightforward to apply version updates to individual projects.

When I run a sonar build with ./gradlew sonar , I encounter an error. Interestingly, the sonar task defined via the Gradle button skips tasks like ladm-commons:compileJava with FROM-CACHE and doesn’t cause any issues.
However, since I’m using a Jenkinsfile and utilizing a pipeline, I execute the ./gradlew sonar command, which results in an error.

I’ve applied sonar.gradle.skipCompile=true, but the same error still occurs.
Did I apply it correctly as follows?

...
plugins {
    id 'org.sonarqube' version '3.5.0.2730'
}

allprojects { project ->
    apply plugin: 'org.sonarqube'
    sonar {
        properties {
            property "sonar.projectKey", determineSonarProjectKey(project.name)
            property "sonar.host.url", "https://sonar.linecorp.com"
            property "sonar.login", determineSonarLogin(project.name)
            property "sonar.gradle.skipCompile", "true"
        }
    }
}
...

Hi,

That looks right to me. Could we get a full log from ./gradlew sonar --info?

 
Ann

Hi, thank you for your support

here is the log from ./gradlew sonar --info

> Configure project :ladm-commons
Evaluating project ':ladm-commons' using build file '/Users/user/Projects/fork/test/ladm-adsvc/ladm-commons/build.gradle'.
All projects evaluated.
Selected primary task 'sonar' from project :
Tasks to be executed: [task ':generateLombokConfig', task ':ladm-commons:compileJava', task ':ladm-commons:processResources', task ':ladm-commons:classes', task ':ladm-commons:jar', task ':compileJava', task ':copyMasterCodesJson', task ':downloadZipFile', task ':generateResourceBundle', task ':setDefaultLocale', task ':processResources', task ':cleanMasterCodesJson', task ':cleanResourceBundle', task ':cleanDynamicResources', task ':classes', task ':compileTestJava', task ':ladm-commons:compileTestJava', task ':sonar']
Tasks that were excluded: []
:generateLombokConfig (Thread[#112,Execution worker for ':',5,main]) started.
:ladm-commons:compileJava (Thread[#115,Execution worker for ':' Thread 4,5,main]) started.

> Task :generateLombokConfig UP-TO-DATE
Caching disabled for task ':generateLombokConfig' because:
  Caching has not been enabled for the task
Skipping task ':generateLombokConfig' as it is up-to-date.
:generateLombokConfig (Thread[#112,Execution worker for ':',5,main]) completed. Took 0.002 secs.
:copyMasterCodesJson (Thread[#112,Execution worker for ':',5,main]) started.

> Task :copyMasterCodesJson UP-TO-DATE
Caching disabled for task ':copyMasterCodesJson' because:
  Caching has not been enabled for the task
Skipping task ':copyMasterCodesJson' as it is up-to-date.
:copyMasterCodesJson (Thread[#112,Execution worker for ':',5,main]) completed. Took 0.002 secs.
:downloadZipFile (Thread[#114,Execution worker for ':' Thread 3,5,main]) started.
This JVM does not support getting OS memory, so no OS memory status updates will be broadcast

> Task :ladm-commons:compileJava FAILED
Build cache key for task ':ladm-commons:compileJava' is b7f157a0dd602ed2bf19de7ce07645dc
Task ':ladm-commons:compileJava' is not up-to-date because:
  Task has failed previously.
The input changes require a full rebuild for incremental task ':ladm-commons:compileJava'.
Full recompilation is required because no incremental change information is available. This is usually caused by clean builds or changing compiler arguments.
Starting process 'Gradle Worker Daemon 2'. Working directory: /Users/user/.gradle/workers Command: /Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java @/private/var/folders/g4/r1y8swhx6mj4bqx58lnlsmtr0000gn/T/gradle-worker-classpath17128619137999631058txt -Xmx512m -Dfile.encoding=UTF-8 -Duser.country=KR -Duser.language=ko -Duser.variant worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Worker Daemon 2'
Successfully started process 'Gradle Worker Daemon 2'
Started Gradle worker daemon (0.163 secs) with fork options DaemonForkOptions{executable=/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java, minHeapSize=null, maxHeapSize=null, jvmArgs=[], keepAliveMode=SESSION}.
Compiling with JDK Java compiler API.
Note: /Users/user/Projects/fork/test/ladm-adsvc/ladm-commons/src/main/java/com/linecorp/lad/manager/commons/targeting/sync/LadsAdvancedTargetingSpec.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:ladm-commons:compileJava (Thread[#115,Execution worker for ':' Thread 4,5,main]) completed. Took 1.198 secs.

> Task :downloadZipFile
Caching disabled for task ':downloadZipFile' because:
  Caching has not been enabled for the task
Task ':downloadZipFile' is not up-to-date because:
  Task.upToDateWhen is false.
Download http://xlt-api.linecorp.com/downloadXLT/LAD%20Manager/WEB%20BROWSER/10.1.0.nhn?format=properties&ignore=true
:downloadZipFile (Thread[#114,Execution worker for ':' Thread 3,5,main]) completed. Took 5.403 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':ladm-commons:compileJava'.
> java.lang.ExceptionInInitializerError

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 5s
4 actionable tasks: 2 executed, 2 up-to-date
Stopped 1 worker daemon(s).

Hi,

That^ doesn’t look like an --info log. Could you try it again with --debug? If that doesn’t produce reams and reams of logs, we know for sure something’s up.

 
Ann

Thank you Ann, removed some logs that I thought was unnecessary,

Here’s the full log with --info,
--debug produce reams of log, if you need I will give that one too

Initialized native services in: /Users/user/.gradle/native
The client will now receive all logging from the daemon (pid: 17054). The daemon log file: /Users/user/.gradle/daemon/6.4.1/daemon-17054.out.log
Starting 3rd build in daemon [uptime: 1 mins 38.984 secs, performance: 100%]
Using 10 worker leases.
Starting Build
Settings evaluated using settings file '/Users/user/Projects/fork/test/ladm-adsvc/settings.gradle'.
Using local directory build cache for the root build (location = /Users/user/.gradle/caches/build-cache-1, removeUnusedEntriesAfter = 7 days).
Projects loaded. Root project using build file '/Users/user/Projects/fork/test/ladm-adsvc/build.gradle'.
Included projects: [root project 'ladm-adsvc', project ':ladm-commons']

> Configure project :
Evaluating root project 'ladm-adsvc' using build file '/Users/user/Projects/fork/test/ladm-adsvc/build.gradle'.
Applying dependency management to configuration 'bootArchives' in project 'ladm-adsvc'
Applying dependency management to configuration 'archives' in project 'ladm-adsvc'
Applying dependency management to configuration 'default' in project 'ladm-adsvc'
Applying dependency management to configuration 'compile' in project 'ladm-adsvc'
Applying dependency management to configuration 'implementation' in project 'ladm-adsvc'
Applying dependency management to configuration 'runtime' in project 'ladm-adsvc'
Applying dependency management to configuration 'compileOnly' in project 'ladm-adsvc'
Applying dependency management to configuration 'compileClasspath' in project 'ladm-adsvc'
Applying dependency management to configuration 'annotationProcessor' in project 'ladm-adsvc'
Applying dependency management to configuration 'runtimeOnly' in project 'ladm-adsvc'
Applying dependency management to configuration 'runtimeClasspath' in project 'ladm-adsvc'
Applying dependency management to configuration 'testCompile' in project 'ladm-adsvc'
Applying dependency management to configuration 'testImplementation' in project 'ladm-adsvc'
Applying dependency management to configuration 'testRuntime' in project 'ladm-adsvc'
Applying dependency management to configuration 'testCompileOnly' in project 'ladm-adsvc'
Applying dependency management to configuration 'testCompileClasspath' in project 'ladm-adsvc'
Applying dependency management to configuration 'testAnnotationProcessor' in project 'ladm-adsvc'
Applying dependency management to configuration 'testRuntimeOnly' in project 'ladm-adsvc'
Applying dependency management to configuration 'testRuntimeClasspath' in project 'ladm-adsvc'
Applying dependency management to configuration 'apiElements' in project 'ladm-adsvc'
Applying dependency management to configuration 'runtimeElements' in project 'ladm-adsvc'
Applying dependency management to configuration 'testRuntimeElements' in project 'ladm-adsvc'
Applying dependency management to configuration 'unitTest' in project 'ladm-adsvc'
Applying dependency management to configuration 'lombok' in project 'ladm-adsvc'
Applying dependency management to configuration 'jacocoAgent' in project 'ladm-adsvc'
Applying dependency management to configuration 'jacocoAnt' in project 'ladm-adsvc'
Applying dependency management to configuration 'integrationTestCompile' in project 'ladm-adsvc'
Applying dependency management to configuration 'integrationTestImplementation' in project 'ladm-adsvc'
Applying dependency management to configuration 'integrationTestRuntime' in project 'ladm-adsvc'
Applying dependency management to configuration 'integrationTestCompileOnly' in project 'ladm-adsvc'
Applying dependency management to configuration 'integrationTestCompileClasspath' in project 'ladm-adsvc'
Applying dependency management to configuration 'integrationTestAnnotationProcessor' in project 'ladm-adsvc'
Applying dependency management to configuration 'integrationTestRuntimeOnly' in project 'ladm-adsvc'
Applying dependency management to configuration 'integrationTestRuntimeClasspath' in project 'ladm-adsvc'
Applying dependency management to configuration 'integrationTestRuntimeElements' in project 'ladm-adsvc'
Applying dependency management to configuration 'integrationTest' in project 'ladm-adsvc'

> Configure project :ladm-commons
Evaluating project ':ladm-commons' using build file '/Users/user/Projects/fork/test/ladm-adsvc/ladm-commons/build.gradle'.
All projects evaluated.
Selected primary task 'sonar' from project :
Tasks to be executed: [task ':generateLombokConfig', task ':ladm-commons:compileJava', task ':ladm-commons:processResources', task ':ladm-commons:classes', task ':ladm-commons:jar', task ':compileJava', task ':copyMasterCodesJson', task ':downloadZipFile', task ':generateResourceBundle', task ':setDefaultLocale', task ':processResources', task ':cleanMasterCodesJson', task ':cleanResourceBundle', task ':cleanDynamicResources', task ':classes', task ':compileTestJava', task ':ladm-commons:compileTestJava', task ':sonar']
Tasks that were excluded: []
:generateLombokConfig (Thread[#153,Execution worker for ':',5,main]) started.
:ladm-commons:compileJava (Thread[#156,Execution worker for ':' Thread 4,5,main]) started.

> Task :generateLombokConfig UP-TO-DATE
Caching disabled for task ':generateLombokConfig' because:
  Caching has not been enabled for the task
Skipping task ':generateLombokConfig' as it is up-to-date.
:generateLombokConfig (Thread[#153,Execution worker for ':',5,main]) completed. Took 0.001 secs.
:copyMasterCodesJson (Thread[#153,Execution worker for ':',5,main]) started.

> Task :copyMasterCodesJson UP-TO-DATE
Caching disabled for task ':copyMasterCodesJson' because:
  Caching has not been enabled for the task
Skipping task ':copyMasterCodesJson' as it is up-to-date.
:copyMasterCodesJson (Thread[#153,Execution worker for ':',5,main]) completed. Took 0.001 secs.
:downloadZipFile (Thread[#153,Execution worker for ':',5,main]) started.
This JVM does not support getting OS memory, so no OS memory status updates will be broadcast

> Task :ladm-commons:compileJava FAILED
Build cache key for task ':ladm-commons:compileJava' is b7f157a0dd602ed2bf19de7ce07645dc
Task ':ladm-commons:compileJava' is not up-to-date because:
  Task has failed previously.
The input changes require a full rebuild for incremental task ':ladm-commons:compileJava'.
Full recompilation is required because no incremental change information is available. This is usually caused by clean builds or changing compiler arguments.
Starting process 'Gradle Worker Daemon 3'. Working directory: /Users/user/.gradle/workers Command: /Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java @/private/var/folders/g4/r1y8swhx6mj4bqx58lnlsmtr0000gn/T/gradle-worker-classpath13742840119245655194txt -Xmx512m -Dfile.encoding=UTF-8 -Duser.country=KR -Duser.language=ko -Duser.variant worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Worker Daemon 3'
Successfully started process 'Gradle Worker Daemon 3'
Started Gradle worker daemon (0.164 secs) with fork options DaemonForkOptions{executable=/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java, minHeapSize=null, maxHeapSize=null, jvmArgs=[], keepAliveMode=SESSION}.
Compiling with JDK Java compiler API.
Note: /Users/user/Projects/fork/test/ladm-adsvc/ladm-commons/src/main/java/com/linecorp/lad/manager/commons/targeting/sync/LadsAdvancedTargetingSpec.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:ladm-commons:compileJava (Thread[#156,Execution worker for ':' Thread 4,5,main]) completed. Took 1.101 secs.

> Task :downloadZipFile
Caching disabled for task ':downloadZipFile' because:
  Caching has not been enabled for the task
Task ':downloadZipFile' is not up-to-date because:
  Task.upToDateWhen is false.
Download http://xlt-api.linecorp.com/downloadXLT/LAD%20Manager/WEB%20BROWSER/10.1.0.nhn?format=properties&ignore=true
:downloadZipFile (Thread[#153,Execution worker for ':',5,main]) completed. Took 6.311 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':ladm-commons:compileJava'.
> java.lang.ExceptionInInitializerError

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 6s
4 actionable tasks: 2 executed, 2 up-to-date
Stopped 1 worker daemon(s).

Hi,

Thanks for the log. Can you just clarify the command this was the result of?

 
Thx,
Ann

Yes, this was the full log result of ./gradlew sonar --info

Thx,

Hi,

Thanks for the confirmation.

On getting your latest response, I reviewed the earlier parts of the thread, and I realized that your version of the SonarScanner for Gradle is the problem. sonar.gradle.skipCompile was only added in version 4.4.1.3373 of the scanner. So can you upgrade and try again?

 
Thx,
Ann

Thank you for your continued assistance.
I understand that the skipCompile option is only available for SonarQube versions 4.4.1.3373 and above.
However, our current project relies on a separate SonarQube server provided by the company, which is currently at version 3.5.0.2730. Is there any alternative to the skipCompile method? I’ve tried various approaches, but all have failed so far.

Hi,

Uhm… No? You’ll find your SonarQube server version in the page footer. I’m fairly confident it’s not 3.5.0.2730 (at least partly because we didn’t use the build number way back then).

You should be able to upgrade the version of SonarScanner for Gradle in your project’s own files, independent of your SonarQube server version.

Well, the failure seems to be in the extra compilation that analysis is forcing to happen, so the choices are fixing that compile error or preventing the compile attempt altogether. Since your normal compile runs fine, skipping the extra compile seems the most expedient course to me…

 
Ann