Skip to content

Commit 479cead

Browse files
committed
aaaaaaaaa
1 parent 156af72 commit 479cead

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

buildSrc/src/main/kotlin/toolkit-detekt.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dependencies {
1616
detektPlugins(project(":detekt-rules"))
1717
}
1818

19+
// detekt with type introspection configured in kotlin conventions
1920
private val detektFiles = fileTree(projectDir).matching {
2021
include("**/*.kt", "**/*.kts")
2122
exclude("**/build")
@@ -34,8 +35,6 @@ detekt {
3435
val javaVersion = project.jvmTarget().get()
3536

3637
tasks.withType<Detekt>().configureEach {
37-
setSource(source.filter { it.walkBottomUp().none { c -> c.name == "build" } })
38-
3938
jvmTarget = javaVersion.majorVersion
4039
dependsOn(":detekt-rules:assemble")
4140

buildSrc/src/main/kotlin/toolkit-kotlin-conventions.gradle.kts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,20 @@ project.afterEvaluate {
5959
}
6060
}
6161
}
62+
63+
// detekt applies sources directly from source sets in this scenario
64+
// can't figure out why source is empty in the detekt conventions
65+
project.extensions.getByType(KotlinJvmProjectExtension::class.java).target.compilations.configureEach {
66+
// can't figure out why exclude("build/**") doesn't work
67+
fun FileTree.withoutBuild() = filter { f -> f.path.split(File.separatorChar).none { it == "build" } }.asFileTree
68+
69+
tasks.named<Detekt>(DetektPlugin.DETEKT_TASK_NAME + name.capitalize()).configure {
70+
source.forEach { it.walkBottomUp().onEnter { c -> println(c); !c.name.startsWith("build") } }
71+
source = source.withoutBuild()
72+
println(source.files)
73+
}
74+
75+
tasks.named<DetektCreateBaselineTask>(DetektPlugin.BASELINE_TASK_NAME + name.capitalize()).configure {
76+
source = source.withoutBuild()
77+
}
78+
}

0 commit comments

Comments
 (0)