Karol Ksionek
07/29/2021, 10:55 AMdetekt {
input = files(escapedProjectDir)
baseline = file("$escapedRootProjectDir/config/detekt/detekt-baseline.xml")
config = files("$escapedRootProjectDir/config/detekt/detekt.yml")
autoCorrect = false
parallel = true
}
tasks.withType(io.gitlab.arturbosch.detekt.Detekt) {
exclude '**/resources/**'
exclude '**/build/**'
}
But it keeps checking build directory. What’s wrong?
I’m using detekt 1.18.0-RC2gammax
07/29/2021, 11:42 AMescapedProjectDir ?
• Why do you even need this custom configuration? Detekt will not scan the build folder by default.Karol Ksionek
07/29/2021, 11:44 AMKarol Ksionek
07/29/2021, 11:46 AMKarol Ksionek
07/29/2021, 11:56 AMgammax
07/29/2021, 12:08 PMdetektDebug , detetkRelease, detetk<Flavor> as they have the input folders already set up for you.Karol Ksionek
07/29/2021, 12:11 PMgammax
07/29/2021, 12:13 PMper-project approach (i.e. one task per every module, according to the Gradle philosophy).
Having only a single task that runs over all your codebase can lead to situation like the one you’re facing.
Anyway, I believe you could try to replace your exclude **/build/** with:
exclude { element -> element.file.path.contains("build/") }
Please let me know if this helps 👍Karol Ksionek
07/29/2021, 12:23 PMtasks.withType(io.gitlab.arturbosch.detekt.Detekt) {
exclude { element ->
println("DEBUG $element")
element.file.path.contains("build/")
}
}
and DEBUG isn’t ever printed to the consolegammax
07/29/2021, 12:26 PMtasks.withType(io.gitlab.arturbosch.detekt.Detekt).configureEach{
☝️ I believe you missed a configureEach{Karol Ksionek
07/29/2021, 12:36 PMconfigureEach issues are being reportedKarol Ksionek
07/29/2021, 12:36 PMgammax
07/29/2021, 12:37 PMKarol Ksionek
07/29/2021, 12:51 PMKarol Ksionek
07/29/2021, 1:13 PMgammax
07/29/2021, 1:58 PMgammax
07/29/2021, 2:37 PMsubprojects{} and you’re running tasks.withType… at the top level project (that doesn’t have Detekt applied).gammax
07/29/2021, 2:37 PMtasks.withType inside the subprojects{} block it will work:gammax
07/29/2021, 2:37 PMsubprojects {
apply {
plugin("io.gitlab.arturbosch.detekt")
plugin("com.github.ben-manes.versions")
}
detekt {
input = files(escapedProjectDir)
config = rootProject.files("config/detekt/detekt.yml")
parallel = true
}
tasks {
withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
exclude("**/build/**")
}
}
}gammax
07/29/2021, 6:07 PMgammax
07/29/2021, 6:09 PMKarol Ksionek
07/29/2021, 8:18 PMtasks.withType(io.gitlab.arturbosch.detekt.Detekt).configureEach {
println("DEBUG - Doesn't enter here")
it.exclude("**/build/**")
}
tasks.configureEach {
if (it.name.contains("detekt")) {
println("DEBUG Hello, I am here and can exclude! $it ${it.class}")
it.exclude("**/build/**")
}
}
And withType doesn’t exclude build dir, but checking by name does!
so looks like my issue is related to gradle itself. I have this configuration in separate file detekt.gradle - had no idea that it may have any meaning.
https://github.com/gradle/gradle-native/issues/742
Well… Gradle/Groovy - surprises on each corner….
Thanks for your help though!gammax
07/29/2021, 8:19 PM