Sonar plugin 4.1.0.3113 & 4.2.0.3129 errors

After updating from SonarQube Gradle plugin 4.0.0.2929 β†’ 4.1.0.3113 our CI build is failing when executing the sonar task with the following messages:

+ ./gradlew sonar
Encryption of the configuration cache is enabled.
Calculating task graph as no configuration cache is available for tasks: sonar

1 problem was found storing the configuration cache.
- Task `:sonar` of type `org.sonarqube.gradle.SonarTask`: error writing value of type 'org.gradle.api.internal.provider.DefaultMapProperty'

See the complete report at file:///home/jenkins/agent/workspace/oid_app_renovate_sonarqubeplugin/build/reports/configuration-cache/cfswrb5ii8p68ov5cxoo5wm5x/2nknctsxq4b5fvpzo31e15vvv/configuration-cache-report.html

FAILURE: Build failed with an exception.

* What went wrong:
Could not load the value of field `properties` of task `:sonar` of type `org.sonarqube.gradle.SonarTask`.
> Unexpected provider value

* 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

BUILD FAILED in 21s

When disabling configuration cache we see another error:

+ ./gradlew sonar -no-configuration-cache

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':sonar'.
> class org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension_Decorated cannot be cast to class org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension (org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension_Decorated and org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader @4379221a)

* 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
[
BUILD FAILED in 40s

Both errors did not occur with previous version 4.0.0.2929.

We are using Gradle 8.1.1 in an Android project (Android gradle plugin 8.0.2).

4 Likes

Same here on a non-Android project

> class org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension_Decorated cannot be cast to class org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension (org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension_Decorated and org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @787bf67f)

Duplicates:

3 Likes

Same here for a Kotlin Springboot Project on Azure DevOps Pipeline

* What went wrong:
Execution failed for task ':sonarqube'.
> class org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension_Decorated cannot be cast to class org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension (org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension_Decorated and org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader @9402283)

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

1 Like

seems to be fixed in β€œ4.2.0.3129”

1 Like

@swerfel Nope, on our Android project it is still failing with 4.2.0.3129 (because of configuration cache) and if we disable it we now get this new error message:

+ ./gradlew sonar -no-configuration-cache
> Task :sonar FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':sonar'.
> java.lang.UnsupportedOperationException (no error message)

BUILD FAILED in 38s
1 Like

We’re also getting the same issue as OP (both 4.1.0 and 4.2.0).

On 4.2.0, we are also disabling the analysis cache:

plugins {
    id "org.sonarqube" version "4.2.0.3129"
}
...
sonarqube {
    ...
    properties {
        ...
        property "sonar.analysisCache.enabled", false
    }

which results in the java.lang.UnsupportedOperationException (no error message) error:

Caused by: java.lang.UnsupportedOperationException
	at org.sonarqube.gradle.SonarUtils.appendProps(SonarUtils.java:125)
	at org.sonarqube.gradle.AndroidUtils.populateSonarQubeProps(AndroidUtils.java:332)
	at org.sonarqube.gradle.AndroidUtils.configureForAndroid(AndroidUtils.java:112)
	at org.sonarqube.gradle.AndroidUtils.configureForAndroid(AndroidUtils.java:89)
	at org.sonarqube.gradle.SonarPropertyComputer.computeSonarProperties(SonarPropertyComputer.java:106)
	at org.sonarqube.gradle.SonarPropertyComputer.computeSonarProperties(SonarPropertyComputer.java:151)
	at org.sonarqube.gradle.SonarPropertyComputer.computeSonarProperties(SonarPropertyComputer.java:91)
	at org.sonarqube.gradle.SonarQubePlugin.lambda$configureTask$2(SonarQubePlugin.java:101)
2 Likes

Same as J Yong here, without changing anything related to cache:

I have the same issue with the UOE in my analysis as op.

I can confirm that 4.2.1.3168 is working now for us (also together with configuration cache).

4.2.1.3168 also works for me!

Can confirm 4.2.1.3168 works for us too.

Still getting the same exception although I bumped Sonar to 4.2.1.3168