4

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?

felipe.rce
  • 237
  • 2
  • 8
  • 35

2 Answers2

2

You can add detekt task before build in Run Configuration

enter image description here

serg3z
  • 1,852
  • 12
  • 28
1

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)
    }
}
Morten Holmgaard
  • 7,484
  • 8
  • 63
  • 85