From a68eb1c533df7e428cd0b56dbd07d68011d1c764 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Fri, 22 May 2026 08:13:36 -0400 Subject: [PATCH] fix(android): migrate detekt block + task types to 2.0 DSL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three breaking changes I missed when bumping to 2.0.0-alpha.3: 1. Gradle plugin id changed: io.gitlab.arturbosch.detekt -> dev.detekt 2. Task FQN changed: io.gitlab.arturbosch.detekt.Detekt -> dev.detekt.gradle.Detekt (same for DetektCreateBaselineTask) 3. jvmTarget is now a Property API (.set("17")) instead of var assignment Also dropped `autoCorrect` from the detekt {} block — it's not in the 2.0 options list per the official getting-started docs. Per the 2.0 release notes: "the workaround of disabling the new DSL and built-in Kotlin via gradle.properties for AGP 9.x projects is no longer required" — so our existing AGP 9 + built-in-Kotlin setup is expected to work cleanly with detekt 2.0. Co-Authored-By: Claude Opus 4.7 (1M context) --- android/app/build.gradle.kts | 18 +++++++++--------- android/gradle/libs.versions.toml | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 1cd9db81..ce912a70 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -94,18 +94,18 @@ detekt { config.setFrom(files("$rootDir/config/detekt.yml")) buildUponDefaultConfig = true parallel = true - autoCorrect = false + // `autoCorrect` was dropped in detekt 2.0's DSL options list. } -// detekt 1.23.7 bundles kotlin-compiler-embeddable 1.9.10, which caps -// `--jvm-target` at 22. The runner's JDK is 25 and detekt would auto- -// detect that, so pin the analyzer target to match our actual bytecode -// target (17). -tasks.withType().configureEach { - jvmTarget = "17" +// detekt 2.0 moved its task types to the `dev.detekt.gradle` package and +// flipped `jvmTarget` to the Property API. Pin to 17 to match our actual +// bytecode target (compileOptions.targetCompatibility + +// kotlin.compilerOptions.jvmTarget). +tasks.withType().configureEach { + jvmTarget.set("17") } -tasks.withType().configureEach { - jvmTarget = "17" +tasks.withType().configureEach { + jvmTarget.set("17") } dependencies { diff --git a/android/gradle/libs.versions.toml b/android/gradle/libs.versions.toml index c86931f2..03978ea3 100644 --- a/android/gradle/libs.versions.toml +++ b/android/gradle/libs.versions.toml @@ -86,4 +86,4 @@ ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" } compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint-gradle" } -detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" } +detekt = { id = "dev.detekt", version.ref = "detekt" }