Hi, I’m trying to add Sonar Gradle plugin to our project.
We have a huge project with many modules applying Android Gradle Plugin but some of them only applying Java Gradle Plugin.
On the modules that only apply Java Gradle Plugin we get:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':sonar'.
> Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Failed to transform module1.jar (project :common:module1) 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=21, org.gradle.libraryelements=jar, org.gradle.usage=java-api, org.jetbrains.kotlin.platform.type=jvm}.
> Execution failed for IdentityTransform: /builds/mobile/common/module1/build/libs/module1.jar.
> File/directory does not exist: /builds/mobile/common/module1/build/libs/module1.jar
> Failed to transform module2.jar (project :common:module2) 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=21, org.gradle.libraryelements=jar, org.gradle.usage=java-api, org.jetbrains.kotlin.platform.type=jvm}.
> Execution failed for IdentityTransform: /builds/mobile/common/module2/build/libs/module2.jar.
> File/directory does not exist: /builds/mobile/common/module2/build/libs/module2.jar
...
(I obfuscated names of module1 and module2)
We have this in our Gradle convention plugin that we apply to Java/Kotlin only modules:
rootProject.tasks.named("sonar") {
dependsOn(tasks.named("jar"))
}
Even though the “jar” tasks get executed before the “sonar” task, this doesn’t fix the issue.
Do you have any suggestion on how to make sure these jars are created before sonar task runs?
Thank you