Command ./gradlew sonar does not work locally

Hi there!

I am having some trouble while trying to run a local scan of my project.

This is one command I have been trying to run:


./gradlew sonar -Dsonar.projectKey=xyz -Dsonar.projectName='xyz' -Dsonar.host.url=https://sonarenterprise.xyz.com -Dsonar.token=xyz

I tried what was suggested in other threads but haven’t succeeded.

  • My project uses Spring Boot 3.3.0, Java 21

  • I have the following plugin in my build.gradle file: id "org.sonarqube" version "4.2.1.3168". Sonar recommended that version. I tried with the latest version 5.0.0.4638 and other versions.

  • The project is hosted on https://sonarenterprise.xyz.com/ (I put xyz to keep it anonymous)

This is the output when I run the ./gradlew sonar command


> Task :sonar FAILED

FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ':sonar'.

> Unable to execute SonarScanner analysis

* Try:

> Run with --stacktrace option to get the stack trace.

> Run with --info or --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 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.5/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD FAILED in 51s

5 actionable tasks: 4 executed, 1 up-to-date

Logs using the --info flag:

--info logs

Initialized native services in: /Users/xyz/.gradle/native

Initialized jansi services in: /Users/xyz/.gradle/native

Received JVM installation metadata from '/Users/xyz/.sdkman/candidates/java/21.0.3-amzn': {JAVA_HOME=/Users/xyz/.sdkman/candidates/java/21.0.3-amzn, JAVA_VERSION=21.0.3, JAVA_VENDOR=Amazon.com Inc., RUNTIME_NAME=OpenJDK Runtime Environment, RUNTIME_VERSION=21.0.3+9-LTS, VM_NAME=OpenJDK 64-Bit Server VM, VM_VERSION=21.0.3+9-LTS, VM_VENDOR=Amazon.com Inc., OS_ARCH=aarch64}

The client will now receive all logging from the daemon (pid: 41823). The daemon log file: /Users/xyz/.gradle/daemon/8.5/daemon-41823.out.log

Starting 5th build in daemon [uptime: 2 hrs 51 mins 54.223 secs, performance: 98%, GC rate: 0.00/s, heap usage: 0% of 4 GiB]

Using 10 worker leases.

Now considering [/Users/xyz/Documents/11-19 HD/11 Repositories/backend] as hierarchies to watch

Watching the file system is configured to be enabled if available

File system watching is active

Starting Build

Settings evaluated using settings file '/Users/xyz/Documents/11-19 HD/11 Repositories/backend/settings.gradle'.

Projects loaded. Root project using build file '/Users/xyz/Documents/11-19 HD/11 Repositories/backend/build.gradle'.

Included projects: [root project 'backend']

> Configure project :

Evaluating root project 'backend' using build file '/Users/xyz/Documents/11-19 HD/11 Repositories/backend/build.gradle'.

Adding download licenses extension

Applying defaults to download task: :downloadLicenses

All projects evaluated.

Task name matched 'sonar'

Selected primary task 'sonar' from project :

Tasks to be executed: [task ':compileJava', task ':bootBuildInfo', task ':processResources', task ':classes', task ':compileTestJava', task ':sonar']

Tasks that were excluded: []

Resolve mutations for :compileJava (Thread[#349,Execution worker,5,main]) started.

:compileJava (Thread[#349,Execution worker,5,main]) started.

> Task :compileJava

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik/org/projectlombok/lombok/maven-metadata.xml)]

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik/org/ehcache/ehcache/maven-metadata.xml)]

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik/org/dom4j/dom4j/maven-metadata.xml)]

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik/com/here/account/here-oauth-client/maven-metadata.xml)]

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik/org/apache/tika/tika-parsers-standard-package/maven-metadata.xml)]

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik/org/apache/tika/tika-core/maven-metadata.xml)]

Cached resource https://repository.mulesoft.org/nexus/content/repositories/public/org/apache/tika/tika-core/2.3.1-SNAPSHOT/maven-metadata.xml is up-to-date (lastModified: Sun Mar 20 01:31:59 COT 2022).

Cached resource https://repository.mulesoft.org/nexus/content/repositories/public/org/apache/tika/tika-core/2.3.1-SNAPSHOT/tika-core-2.3.1-20220318.205603-70.pom is up-to-date (lastModified: Fri Mar 18 17:17:44 COT 2022).

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik/org/apache/tika/tika-parent/2.3.1-SNAPSHOT/maven-metadata.xml)]

Cached resource https://repository.mulesoft.org/nexus/content/repositories/public/org/apache/tika/tika-parent/2.3.1-SNAPSHOT/maven-metadata.xml is up-to-date (lastModified: Fri Mar 18 17:18:31 COT 2022).

Cached resource https://repository.mulesoft.org/nexus/content/repositories/public/org/apache/tika/tika-parent/2.3.1-SNAPSHOT/tika-parent-2.3.1-20220318.221831-77.pom is up-to-date (lastModified: Fri Mar 18 17:18:31 COT 2022).

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik/me/nimavat/shortid/1.0.1.RC1/shortid-1.0.1.RC1.pom)]

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik/com/github/grumlimited/geocalc/0.5.1/geocalc-0.5.1.pom)]

Cached resource https://repository.mulesoft.org/nexus/content/repositories/public/org/apache/tika/tika-core/2.3.1-SNAPSHOT/tika-core-2.3.1-20220318.205603-70.jar is up-to-date (lastModified: Fri Mar 18 17:17:43 COT 2022).

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik/org/projectlombok/lombok/maven-metadata.xml)]

Caching disabled for task ':compileJava' because:

Build cache is disabled

Task ':compileJava' is not up-to-date because:

Input property 'classpath' file /Users/xyz/.gradle/caches/modules-2/files-2.1/org.apache.tika/tika-core/2.3.0/aaed656e1acf142da412d468405038104c0cf38b/tika-core-2.3.0.jar has been removed.

Input property 'classpath' file /Users/xyz/.gradle/caches/modules-2/files-2.1/org.apache.tika/tika-core/2.3.1-SNAPSHOT/93c416765d6b11b6aa3f6fcdb448cec19c87bcc4/tika-core-2.3.1-SNAPSHOT.jar has been added.

Created classpath snapshot for incremental compilation in 0.11 secs.

Full recompilation is required because pem_password_cb.class could not be analyzed for incremental compilation. See the debug log for more details. Analysis took 1.25 secs.

Compiling with toolchain '/Users/xyz/.sdkman/candidates/java/21.0.3-amzn'.

Compiling with JDK Java compiler API.

Class dependency analysis for incremental compilation took 0.103 secs.

Resolve mutations for :bootBuildInfo (Thread[#349,Execution worker,5,main]) started.

:bootBuildInfo (Thread[#349,Execution worker,5,main]) started.

> Task :bootBuildInfo

Caching disabled for task ':bootBuildInfo' because:

Build cache is disabled

Task ':bootBuildInfo' is not up-to-date because:

Value of input property 'properties.timeIfNotExcluded' has changed for task ':bootBuildInfo'

Resolve mutations for :processResources (Thread[#349,Execution worker,5,main]) started.

:processResources (Thread[#349,Execution worker,5,main]) started.

> Task :processResources UP-TO-DATE

Caching disabled for task ':processResources' because:

Build cache is disabled

Skipping task ':processResources' as it is up-to-date.

Resolve mutations for :classes (Thread[#349,Execution worker,5,main]) started.

:classes (Thread[#349,Execution worker,5,main]) started.

> Task :classes

Skipping task ':classes' as it has no actions.

Resolve mutations for :compileTestJava (Thread[#349,Execution worker,5,main]) started.

:compileTestJava (Thread[#349,Execution worker,5,main]) started.

> Task :compileTestJava

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik/org/projectlombok/lombok/maven-metadata.xml)]

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik/org/ehcache/ehcache/maven-metadata.xml)]

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik/org/dom4j/dom4j/maven-metadata.xml)]

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik/com/here/account/here-oauth-client/maven-metadata.xml)]

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik/org/apache/tika/tika-parsers-standard-package/maven-metadata.xml)]

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik/org/apache/tika/tika-core/maven-metadata.xml)]

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik/me/nimavat/shortid/1.0.1.RC1/shortid-1.0.1.RC1.pom)]

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik/com/github/grumlimited/geocalc/0.5.1/geocalc-0.5.1.pom)]

Failed to get resource: GET. [HTTP HTTP/1.1 403 Forbidden: https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik/org/projectlombok/lombok/maven-metadata.xml)]

Caching disabled for task ':compileTestJava' because:

Build cache is disabled

Task ':compileTestJava' is not up-to-date because:

Input property 'classpath' file /Users/xyz/.gradle/caches/modules-2/files-2.1/org.apache.tika/tika-core/2.3.0/aaed656e1acf142da412d468405038104c0cf38b/tika-core-2.3.0.jar has been removed.

Input property 'classpath' file /Users/xyz/.gradle/caches/modules-2/files-2.1/org.apache.tika/tika-core/2.3.1-SNAPSHOT/93c416765d6b11b6aa3f6fcdb448cec19c87bcc4/tika-core-2.3.1-SNAPSHOT.jar has been added.

Created classpath snapshot for incremental compilation in 0.161 secs.

Full recompilation is required because pem_password_cb.class could not be analyzed for incremental compilation. See the debug log for more details. Analysis took 0.939 secs.

Compiling with toolchain '/Users/xyz/.sdkman/candidates/java/21.0.3-amzn'.

Compiling with JDK Java compiler API.

Class dependency analysis for incremental compilation took 0.019 secs.

Resolve mutations for :sonar (Thread[#349,Execution worker,5,main]) started.

:sonar (Thread[#349,Execution worker,5,main]) started.

> Task :sonar FAILED

JaCoCo report task detected, but XML report is not enabled or it was not produced. Coverage for this task will not be reported.

Caching disabled for task ':sonar' because:

Build cache is disabled

Task ':sonar' is not up-to-date because:

Task has not declared any outputs despite executing actions.

User cache: /Users/xyz/.sonar/cache

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.5/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

5 actionable tasks: 4 executed, 1 up-to-date

Watched directory hierarchies: [/Users/xyz/Documents/11-19 HD/11 Repositories/backend]

Any help is well appreciated :slightly_smiling_face:

Hi,

Are you sure this is a --info log? It doesn’t seem to have added much information. If this really is a --info log, then - much as I hesitate to suggest this - it looks like you’ll need to get a --debug log.

And, I think it’s worth noting that there’s already a lot identifiably wrong in the log you already have:

Whether or not these 403s have an impact on analysis, it’s worth getting them handled since they’re likely having an impact on your compilation.

 
Ann

1 Like

Hi Ann! Thanks much for your reply.

In the end, we managed to solve it. Since we didn’t set up the enterprise Sonarqube, we found in the logs a redirection to an HTML page that is about an Azure SSO login.

Our team provided us with a special agent that allows us to run sonar commands.

1 Like