From 1bcd8fd9d62a00bf5860a0214378415130b42765 Mon Sep 17 00:00:00 2001 From: Daniel Lin Date: Mon, 2 Dec 2024 21:15:06 -0500 Subject: [PATCH] Wire up Detekt --- kt/aoc2024-exe/build.gradle.kts | 11 ++++++++++- kt/aoc2024-lib/build.gradle.kts | 9 +++++++++ kt/build.gradle.kts | 10 +++++++++- kt/config/detekt/detekt.yml | 3 +++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 kt/config/detekt/detekt.yml diff --git a/kt/aoc2024-exe/build.gradle.kts b/kt/aoc2024-exe/build.gradle.kts index a7f4837c..8e9647c4 100644 --- a/kt/aoc2024-exe/build.gradle.kts +++ b/kt/aoc2024-exe/build.gradle.kts @@ -24,7 +24,7 @@ kotlin { it.binaries.executable { entryPoint("com.github.ephemient.aoc2024.exe.main") } - } + }, ).onEach { it.compilations { create("bench") { @@ -66,6 +66,15 @@ kotlin { } } } + + val detektTaskNames = targets.flatMap { target -> + target.compilations.map { compilation -> + "detekt${target.targetName.capitalize()}${compilation.compilationName.capitalize()}" + } + } + tasks.check { + dependsOn(detektTaskNames) + } } dependencies { diff --git a/kt/aoc2024-lib/build.gradle.kts b/kt/aoc2024-lib/build.gradle.kts index 2ade09d8..905bb7a0 100644 --- a/kt/aoc2024-lib/build.gradle.kts +++ b/kt/aoc2024-lib/build.gradle.kts @@ -44,6 +44,15 @@ kotlin { } } } + + val detektTaskNames = targets.flatMap { target -> + target.compilations.map { compilation -> + "detekt${target.targetName.capitalize()}${compilation.compilationName.capitalize()}" + } + } + tasks.check { + dependsOn(detektTaskNames) + } } val jvmTestCompilation = kotlin.jvm().compilations.getByName("test") diff --git a/kt/build.gradle.kts b/kt/build.gradle.kts index b90aca3e..8f8e53c1 100644 --- a/kt/build.gradle.kts +++ b/kt/build.gradle.kts @@ -1,7 +1,15 @@ plugins { + base alias(libs.plugins.kotlin.multiplatform) apply false alias(libs.plugins.kotlin.plugin.allopen) apply false + alias(libs.plugins.detekt) alias(libs.plugins.kotlinx.benchmark) apply false } -group = "com.github.ephemient.aoc2024" +dependencies { + detektPlugins(libs.bundles.detekt.plugins) +} + +detekt { + source.from(allprojects.map { it.buildFile }) +} diff --git a/kt/config/detekt/detekt.yml b/kt/config/detekt/detekt.yml new file mode 100644 index 00000000..a1e6cd29 --- /dev/null +++ b/kt/config/detekt/detekt.yml @@ -0,0 +1,3 @@ +style: + MagicNumber: + active: false