Sonar Gradle plugin starts unwanted wrapper download

When I execute Sonar Gradle plugin, it tries to download Gradle Wrapper:

> Task :sonar
The version of Java (11.0.19) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.
Could not report issue with code highlighting, using plain text instead. Check whether the product is outdated.
java.lang.UnsupportedOperationException: null
Downloading https://services.gradle.org/distributions/gradle-8.2.1-bin.zip
..........................................................................................................................
> Task :sonar

I have Gradle in my CI Docker image. I don’t want any download of Gradle wrapper. This consumes time and network bandwidth and serves nothing. I execute Gradle using gradle sonar, not ./gradlew sonar.

This started happening in version 4.3.1.3277 of the Sonar plugin. Still happens in 4.4.0.3356. Does not happen in 4.2.1.3168. So I am stuck to using 4.2.

Sonar plugin is the only thing causing download of the Gradle wrapper. No other Gradle task I execute does it.

Hello @pkubowicz,

Thanks for your message. This is indeed a strange behavior. In order to help me investigate the issue, could you, please share:

  • a minimal reproducer
  • full logs
  • how do you configure sonar

Let me know if you can only share it in the DM, and I will open it for you.

Best,
Margarita

We have the same issue

We have the same issue too. When downgrading into 4.2.1.3168, the issue disappears.

I see independent 3 people having the same problem, so I suppose it’s easy to reproduce.

Margarita_Nedzelska I suggest you at least try to reproduce it. Steps are pretty clear (run the build from a Docker image based on gradle:8.2.1-jdk17-focal). In case you have problems in reproducing, let me know and I will try to see what I can do.

Hello @pkubowicz,

I can see that a couple of people have a similar problem here and I would like to help you investigate the issue and fix it.

However, I would like you to understand that the community forum isn’t paid customer support. It’s a forum where we try to provide our help according to our availability. That’s why threads with proper reproducers and full data (logs, configuration, etc) get higher priority.

If you say that the steps to reproduce are very simple. Then I don’t understand what stops you from providing me the sample project with a Dokerfile. So I can save my time setting up everything and focus on investigating why this issue is happening.

Thanks for understanding.

Best,
Margarita

Here is the project: Piotr Kubowicz / sonar-gradle-wrapper-bug · GitLab

You can clone it, set SONAR_PROJECT_KEY and SONAR_HOST environment variables and you will see the incorrect download started.

The problem appears for me when I set my company’s key and host. You won’t see the bug appearing because this is my personal repository, without access to a Sonar key.

@pkubowicz Thanks for the project.

I think I know what’s happening. Currently, we depend on Gradle Tooling Api for analyzing Gradle Build scripts. And it triggers the download of Gradle distribution.

We will discuss within the team what would be the best solution for such a problem. For now, I created a ticket to track the issue:

https://sonarsource.atlassian.net/browse/SONARKT-372

Best,
Margarita

1 Like