File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ dependencies {
1616 detektPlugins(project(" :detekt-rules" ))
1717}
1818
19+ // detekt with type introspection configured in kotlin conventions
1920private val detektFiles = fileTree(projectDir).matching {
2021 include(" **/*.kt" , " **/*.kts" )
2122 exclude(" **/build" )
@@ -34,8 +35,6 @@ detekt {
3435val javaVersion = project.jvmTarget().get()
3536
3637tasks.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
Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments