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

Francis Mariano

02/28/2023, 2:23 PM
hello everyone. I am following some instrctions to execute detekt in entire project, so now I have the task :
Copy code
tasks.register("detektAll") {
    allprojects {
        this@register.dependsOn(tasks.withType<io.gitlab.arturbosch.detekt.Detekt>())
    }
}
I would like to run the detektAll in each build, but I unable configure that. Do you know a better approach to run detekt in entire project ???
s

Sam

02/28/2023, 2:30 PM
Gradle uses name-matching execution, so if you run a task in the root project, it will run tasks with that name in every subproject.
f

Francis Mariano

02/28/2023, 2:48 PM
Ok, but I do not understand how to use name-matching execution to run detekt in entire project in each build.
j

Javier

02/28/2023, 3:07 PM
Technically you are not running the task on the rootProject
Supposing you have three projects with detekt task, rootProject (
:
),
a
, and
b
If you run
./gradlew detekt
, it will execute
Copy code
:detekt
:a:detekt
:b:detekt
if you run
./gradlew :detekt
it will execute
Copy code
:detekt
which is the rootProject one
similar for
./gradlew :a:detekt
f

Francis Mariano

02/28/2023, 5:00 PM
ok, i ran shareddetekt but the task does not execute the checks. Is the correct run detektMetadata* tasks and shareddetektAndroidRelease / shareddetektAndroidDebug ???
m

Mustafa Ozhan

03/01/2023, 3:13 PM
You can use the sample i shared here: https://github.com/detekt/detekt/issues/5611#issuecomment-1365505710 It run all the tasks from all the modules plus it support also KMP
8 Views