Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run detekt on all builds

Tags:

android

detekt

It's possible to run detekt before build? (run, release...)

I followed this https://arturbosch.github.io/detekt/gradletask.html

But check.dependsOn detekt on build.gradle (app) don't do nothing...

I already tried check.dependsOn detekt and preBuild.dependsOn detekt

And tried ...dependsOn detektCheck too...

What's the error? I can't use the detektCheck task before build?

like image 621
felipe.rce Avatar asked Oct 21 '25 11:10

felipe.rce


2 Answers

You can add detekt task before build in Run Configuration

enter image description here

like image 86
serg3z Avatar answered Oct 23 '25 02:10

serg3z


One other option is to added it as a part the build, so it could fail the build:

tasks.whenTaskAdded {
    if (name == "compileDebugKotlin") {
        dependsOn(tasks.detekt)
        mustRunAfter(tasks.detekt)
    }
}
like image 28
Morten Holmgaard Avatar answered Oct 23 '25 02:10

Morten Holmgaard