Gradle Kotlin DSL Doctor
Source mapping: Tier 1 critical skill derived from Kotlin_Spring_Developer_Pipeline.md (SK-04).
Mission
Stabilize the build with the smallest defensible change.
Treat Gradle problems as compatibility and model problems, not only syntax problems.
Read First
settings.gradle.kts
- root and module
build.gradle.kts
gradle.properties
gradle/libs.versions.toml or other version catalogs
gradle-wrapper.properties
- the exact Gradle output from the failing task
Classify The Failure
Classify the problem before editing anything:
- plugin resolution or plugin version mismatch
- Kotlin DSL syntax or type-safe accessor issue
- dependency resolution or BOM conflict
- JDK toolchain or target mismatch
- source set or test runtime misconfiguration
- compiler plugin problem such as
plugin.spring, plugin.jpa, KAPT, or KSP
- task wiring or multi-module convention issue
Work Sequence
- Identify the failing task and the first meaningful error line.
- Determine whether the breakage is in plugin resolution, dependency resolution, compilation, test execution, or packaging.
- Extract the current version authorities:
- Spring Boot plugin
- Kotlin plugin
- Gradle wrapper
- JDK toolchain
- version catalog or convention plugin
- Verify whether the project should inherit versions from the Spring Boot BOM instead of declaring them manually.
- Patch the narrowest file possible. Prefer module-local fixes over global rewrites.
- Recommend the smallest verification command that proves the fix before running the full build.
Kotlin And Spring Checks
- Verify
kotlin("plugin.spring") when Spring-managed classes rely on proxies.
- Verify
kotlin("plugin.jpa") when JPA entities are present.
- Verify JVM target and Java toolchain alignment.
- Verify
kotlin-reflect, serialization, and coroutine libraries align with the Kotlin version in use.
- Verify whether annotation processing should use KAPT or KSP in this project.
Preferred Fix Style
- Remove unnecessary explicit versions before adding new ones.
- Let the Spring Boot BOM manage compatible dependency versions whenever possible.
- Prefer small diffs over full-file replacement.
- Preserve existing conventions such as version catalogs, convention plugins, or build logic modules.
- If a fix spans several modules, explain the dependency graph that forces it.
Advanced Build Diagnostics
- Distinguish dependency declaration problems from variant-selection problems. A dependency can exist and still resolve the wrong JVM target, classifier, or capability.
- Check whether the repo uses
platform(...) or enforcedPlatform(...) in addition to the Spring Boot BOM. That changes how conflict resolution behaves.
- Check whether the real plugin source of truth is
pluginManagement, a version catalog, or a convention plugin rather than the module build file.
- Check whether the Boot plugin is applied to library modules that should publish plain jars instead of executable jars.
- Check configuration-cache compatibility if the project is trying to use it. Eager task access and mutable global state in custom build logic often explain strange Gradle behavior.
- Check whether KAPT, KSP, code generation, or source-set wiring requires generated-source directories or task ordering that is currently missing.
- Check dependency locking, verification metadata, or repository policy files before suggesting new repositories or version changes.
- Check test fixtures, included builds, and composite builds when inter-module dependencies behave differently in IDE and CI.
Expert Heuristics
- Prefer explaining which layer owns a version: wrapper, plugin, platform, version catalog, or module override. This avoids repeated drift after the immediate fix.
- If the build fails only in CI, compare wrapper version, JDK vendor,
org.gradle.jvmargs, configuration cache flags, and repository credentials before touching dependency declarations.
- If a custom task or plugin breaks under a new Gradle version, isolate that change from ordinary dependency or Kotlin compiler fixes.
- If the build uses dependency substitution or included builds, verify whether the resolved artifact is local source or published binary before diagnosing API mismatches.
Output Contract
Return these sections:
Root cause: what is broken and at which stage of the build.
Minimal patch: the exact Gradle change to make.
Why this works: the compatibility rule or Gradle model fact behind the patch.
Verification: one or more commands in increasing confidence order.
Follow-up risk: only if the fix unblocks the build but leaves technical debt behind.
Guardrails
- Do not invent random dependency or plugin versions.
- Do not rewrite Kotlin DSL into Groovy or Maven syntax.
- Do not change unrelated modules just because they look similar.
- Do not hide version conflicts with
force or aggressive exclusions unless there is a strong, explicit reason.
- Do not recommend clearing caches as the primary fix when the build model itself is wrong.
High-Signal Commands
Use these when the repository permits command execution:
./gradlew help
./gradlew build
./gradlew :module:compileKotlin
./gradlew dependencies
./gradlew dependencyInsight --dependency <artifact>
Quality Bar
A good run of this skill leaves the build model clearer than before and produces a fix that survives CI.
A bad run throws version guesses at the problem, rewrites too much, or ignores the Spring Boot compatibility model.
1---2name: gradle-kotlin-dsl-doctor3description: Generate, debug, and repair Kotlin + Spring Gradle builds with minimal, compatible changes. Use when `build.gradle.kts` or `settings.gradle.kts` is failing, plugins or toolchains are incompatible, dependency management is drifting from the Spring Boot BOM, test or runtime classpaths are broken, or a Kotlin DSL patch must be safe and incremental.4---56# Gradle Kotlin DSL Doctor78Source mapping: Tier 1 critical skill derived from `Kotlin_Spring_Developer_Pipeline.md` (`SK-04`).910## Mission1112Stabilize the build with the smallest defensible change.13Treat Gradle problems as compatibility and model problems, not only syntax problems.1415## Read First1617- `settings.gradle.kts`18- root and module `build.gradle.kts`19- `gradle.properties`20- `gradle/libs.versions.toml` or other version catalogs21- `gradle-wrapper.properties`22- the exact Gradle output from the failing task2324## Classify The Failure2526Classify the problem before editing anything:2728- plugin resolution or plugin version mismatch29- Kotlin DSL syntax or type-safe accessor issue30- dependency resolution or BOM conflict31- JDK toolchain or target mismatch32- source set or test runtime misconfiguration33- compiler plugin problem such as `plugin.spring`, `plugin.jpa`, KAPT, or KSP34- task wiring or multi-module convention issue3536## Work Sequence37381. Identify the failing task and the first meaningful error line.392. Determine whether the breakage is in plugin resolution, dependency resolution, compilation, test execution, or packaging.403. Extract the current version authorities:41 - Spring Boot plugin42 - Kotlin plugin43 - Gradle wrapper44 - JDK toolchain45 - version catalog or convention plugin464. Verify whether the project should inherit versions from the Spring Boot BOM instead of declaring them manually.475. Patch the narrowest file possible. Prefer module-local fixes over global rewrites.486. Recommend the smallest verification command that proves the fix before running the full build.4950## Kotlin And Spring Checks5152- Verify `kotlin("plugin.spring")` when Spring-managed classes rely on proxies.53- Verify `kotlin("plugin.jpa")` when JPA entities are present.54- Verify JVM target and Java toolchain alignment.55- Verify `kotlin-reflect`, serialization, and coroutine libraries align with the Kotlin version in use.56- Verify whether annotation processing should use KAPT or KSP in this project.5758## Preferred Fix Style5960- Remove unnecessary explicit versions before adding new ones.61- Let the Spring Boot BOM manage compatible dependency versions whenever possible.62- Prefer small diffs over full-file replacement.63- Preserve existing conventions such as version catalogs, convention plugins, or build logic modules.64- If a fix spans several modules, explain the dependency graph that forces it.6566## Advanced Build Diagnostics6768- Distinguish dependency declaration problems from variant-selection problems. A dependency can exist and still resolve the wrong JVM target, classifier, or capability.69- Check whether the repo uses `platform(...)` or `enforcedPlatform(...)` in addition to the Spring Boot BOM. That changes how conflict resolution behaves.70- Check whether the real plugin source of truth is `pluginManagement`, a version catalog, or a convention plugin rather than the module build file.71- Check whether the Boot plugin is applied to library modules that should publish plain jars instead of executable jars.72- Check configuration-cache compatibility if the project is trying to use it. Eager task access and mutable global state in custom build logic often explain strange Gradle behavior.73- Check whether KAPT, KSP, code generation, or source-set wiring requires generated-source directories or task ordering that is currently missing.74- Check dependency locking, verification metadata, or repository policy files before suggesting new repositories or version changes.75- Check test fixtures, included builds, and composite builds when inter-module dependencies behave differently in IDE and CI.7677## Expert Heuristics7879- Prefer explaining which layer owns a version: wrapper, plugin, platform, version catalog, or module override. This avoids repeated drift after the immediate fix.80- If the build fails only in CI, compare wrapper version, JDK vendor, `org.gradle.jvmargs`, configuration cache flags, and repository credentials before touching dependency declarations.81- If a custom task or plugin breaks under a new Gradle version, isolate that change from ordinary dependency or Kotlin compiler fixes.82- If the build uses dependency substitution or included builds, verify whether the resolved artifact is local source or published binary before diagnosing API mismatches.8384## Output Contract8586Return these sections:8788- `Root cause`: what is broken and at which stage of the build.89- `Minimal patch`: the exact Gradle change to make.90- `Why this works`: the compatibility rule or Gradle model fact behind the patch.91- `Verification`: one or more commands in increasing confidence order.92- `Follow-up risk`: only if the fix unblocks the build but leaves technical debt behind.9394## Guardrails9596- Do not invent random dependency or plugin versions.97- Do not rewrite Kotlin DSL into Groovy or Maven syntax.98- Do not change unrelated modules just because they look similar.99- Do not hide version conflicts with `force` or aggressive exclusions unless there is a strong, explicit reason.100- Do not recommend clearing caches as the primary fix when the build model itself is wrong.101102## High-Signal Commands103104Use these when the repository permits command execution:105106- `./gradlew help`107- `./gradlew build`108- `./gradlew :module:compileKotlin`109- `./gradlew dependencies`110- `./gradlew dependencyInsight --dependency <artifact>`111112## Quality Bar113114A good run of this skill leaves the build model clearer than before and produces a fix that survives CI.115A bad run throws version guesses at the problem, rewrites too much, or ignores the Spring Boot compatibility model.