https://kotlinlang.org logo
#detekt
Title
# detekt
m

mkrussel

05/25/2021, 9:08 PM
How would you create a gradle task to run all the detekt targets. I tried.
Copy code
val detektAll = tasks.register("detektAll") {
    dependsOn(tasks.withType<io.gitlab.arturbosch.detekt.Detekt>())
}
This produces errors like
Copy code
Could not determine the dependencies of task ':pangea-map:detektAndroidReleaseUnitTest'.
> Could not resolve all task dependencies for configuration ':pangea-map:releaseUnitTestCompileClasspath'.
   > The consumer was configured to find an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'. However we cannot choose between the following variants of project :pangea-map:
       - Configuration ':pangea-map:releaseApiElements' variant android-aidl declares an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-aidl' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.api.attributes.VariantAttr' with value 'release' but the consumer didn't ask for it
       - Configuration ':pangea-map:releaseApiElements' variant android-manifest declares an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-manifest' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.api.attributes.VariantAttr' with value 'release' but the consumer didn't ask for it
This only seems to be problems on the android detekt tasks on a multiplatform project. Using in on an Android project without multiplatform, produces no errors. I'm also able to add all the non Android tasks by string on a multiplatform project, but the android tasks by strings still fail with the same errors.
Seems like I cannot even run those targets.
s

schalkms

05/25/2021, 9:44 PM
Detekt MPP support is quite young. Can you please check the following issues and verify whether this documentation helps? https://github.com/detekt/detekt/issues/3663 https://github.com/detekt/detekt/issues/3665
m

mkrussel

05/25/2021, 9:46 PM
3663 should what I tried to do as the work around. I think I'm running into a new bug and will open a report.
j

Javier

05/25/2021, 10:48 PM
what you mean all detekt targets?
I run detekt for all projects in kmp with no issues by just running gradlew detekt
m

mkrussel

05/26/2021, 11:14 AM
gradlew detekt detektAndroidDebug detektAndroidRelease detektAndroidDebugUnitTest detektAndroidReleseUnitTest detektIosX64Main detektIosX64Test detektIosArm64Main detektIosArm64Test detektJvmMain detektJvmTest
The other tasks apply type resolution to be able to run more checks.
👍 1
16 Views