Error writing value of type 'org.gradle.api.internal.provider.DefaultMapProperty'

I am trying to execute Gradle sonar task from the command line ./gradlew sonar

  • Using Gradle sonar plugin 4.4.1.3373
  • trying to get an initial report on our Android multi-module project that consists of different flavours that produce different branded apps

Above command will produce the following info logs

./gradlew sonar
Configuration on demand is an incubating feature.
Calculating task graph as configuration cache cannot be reused because file 'build.gradle.kts' has changed.

> Configure project :
The 'sonarqube' task depends on compile tasks. This behavior is now deprecated and will be removed in version 5.x. To avoid implicit compilation, set property 'sonar.gradle.skipCompile' to 'true' and make sure your project is compiled, before analysis has started.
The 'sonar' task depends on compile tasks. This behavior is now deprecated and will be removed in version 5.x. To avoid implicit compilation, set property 'sonar.gradle.skipCompile' to 'true' and make sure your project is compiled, before analysis has started.

> Configure project :dataingestion
The dd-android-gradle-plugin has been applied on a non android application project

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:///Users/MY_ACCOUNT/github/PROJECT_NAME/build/reports/configuration-cache/9huqx05040tw9kprox32immga/6rvrk6u1kelwfs652546x7k0y/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 20s
5 actionable tasks: 5 up-to-date
Configuration cache entry stored with 1 problem.

stacktrace-gradlew-sonar.txt (58.8 KB)

Any advice would be appreciated given projects build fine otherwise

Hi,

Could we get a --info or --debug log?

Because based on your log, it looks like a simple missing file:

org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:netherlandsDebugCompileClasspath'.
...
Caused by: org.gradle.api.internal.artifacts.transform.TransformException: Failed to transform kotlin.jar (project :core:utils:kotlin) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.environment=standard-jvm, org.gradle.jvm.version=17, org.gradle.libraryelements=jar, org.gradle.usage=java-api, org.jetbrains.kotlin.platform.type=jvm}.
...
Caused by: org.gradle.api.internal.artifacts.transform.TransformException: Execution failed for IdentityTransform: /Users/USER_NAME/github/PROJECT_NAME/core/utils/kotlin/build/libs/kotlin.jar.
...
Caused by: java.lang.IllegalArgumentException: File/directory does not exist: /Users/USER_NAME/github/PROJECT_NAME/core/utils/kotlin/build/libs/kotlin.jar

 
Ann

Thank you for reply @ganncamp
The problem seems to originate from a module that is defined and JVM library through Gradle convention plugin
Example of module build.gradle.kts nowinandroid/core/model/build.gradle.kts at main · android/nowinandroid · GitHub

plugins {
    alias(libs.plugins.nowinandroid.jvm.library)
}

dependencies {
    implementation(libs.kotlinx.datetime)
}

where JVM plugin is defined in build-logic module as below nowinandroid/build-logic/convention/src/main/kotlin/JvmLibraryConventionPlugin.kt at main · android/nowinandroid · GitHub

import com.google.samples.apps.nowinandroid.configureKotlinJvm
import org.gradle.api.Plugin
import org.gradle.api.Project

class JvmLibraryConventionPlugin : Plugin<Project> {
    override fun apply(target: Project) {
        with(target) {
            with(pluginManager) {
                apply("org.jetbrains.kotlin.jvm")
                apply("nowinandroid.android.lint")
            }
            configureKotlinJvm()
        }
    }
}

Hi,

Is the implication here that it’s happening during the ‘extra’ build that analyzing with SonarScanner for Gradle forces? If so, can you try adding -Dsonar.gradle.skipCompile=true on the analysis command line? If not… we still need that analysis log.

 
:sweat_smile:
Ann

OK here are logs
gredlew-sonar-info.txt (329.3 KB)

1 Like

Hello @Peter_Miklosko,

Thanks for reaching out. It is failing because you’re using configuration cache and this is an experimental feature and Sonar task is not completely compatible with this (we’re currently working on it).

Meanwhile, it would be really helpful if you could share this report from logs to help us investigate:

See the complete report at file:///Users/USERNAME/github/legoandroid/build/reports/configuration-cache/9huqx05040tw9kprox32immga/89z3s1y6ouu4kfefefufcco5h/configuration-cache-report.html

Meanwhile, you can disable the cache by using options --configuration-cache-problems=warn or --no-configuration-cache .

sonar.gradle.skipCompile won’t help here, because it’s failing during the configuration stage.

Best,
Margarita

Apology for the delay other work had a higher priority

On a positive note, I updated our project from 4.4.1.3373 to 5.0.0.4638 and that is no longer giving me errors. So I will close this thread

2 Likes