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.
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
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.
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.