iliask
12/16/2021, 2:23 PMdetekt
(without type resolution at the moment) always run after assemble
tasks automatically, either through a detekt configuration or some gradle magic?gammax
12/16/2021, 2:24 PMassemble.dependsOn(detektMain)
should do the job for you 👍iliask
12/16/2021, 2:34 PMdetektAll
task in the root build.gradle
tasks.register("detektAll", Detekt) {
...
}
When adding assemble.dependsOn(detektAll)
in the root build.gradle
then gradle sync fails 🤔
Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'assemble' for root project
gammax
12/16/2021, 2:35 PMCould not get unknown property ‘assemble’ for root projectThis happens because you don’t have an
assemble
task (yet)iliask
12/16/2021, 2:38 PM./gradlew tasks
the assemble
task is present.
When I add the suggested snippet in the app module build.gradle
then gradle syncs successfully. Perhaps the assemble tasks are not "seen" by the root build.gradle
?gammax
12/16/2021, 2:41 PMPerhaps the assemble tasks are not “seen” by the rootSort of. The?build.gradle
assemble
task are “local” to your subprojects. While I suppose your detektAll
task is declared in the top level build.gradleiliask
12/16/2021, 2:46 PMgammax
12/16/2021, 2:47 PMdetetkAll
task provided by default?iliask
12/16/2021, 2:49 PMgammax
12/16/2021, 3:09 PMdetektAll
goes against the Gradle philosophyiliask
12/16/2021, 3:18 PMdetektAll
.
Would you recommend instead to add detekt dependency in every module via allprojects {}
or something else?gammax
12/16/2021, 3:21 PM./gradlew detektMain
you’re essentially saying to Gradle to invoke detetkMain
on all the subprojects. That should be sufficient to run detekt on all the subprojects (i.e. you don’t need a detetkAll
).
You can specify the dependency between assemble and detektAll a the project level then.iliask
12/16/2021, 3:28 PMephemient
12/16/2021, 6:22 PMdetekt
is already added as a dependency to the standard check
task, which means if you run either gradle check
or gradle build
, it will also run detekt
gammax
12/16/2021, 8:22 PM