I tried to implement Kotlin check style in project using ktlint. I added
plugins {
id("org.jlleitschuh.gradle.ktlint") version "10.1.0" apply false
}
in root build.gradle.kts and
plugins {
id("org.jlleitschuh.gradle.ktlint")
}
in build.gradle.kts in subprojects
When I called
gradlew ktlintCheck
I got
FAILURE: Build failed with an exception.
* What went wrong:
org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension
How can I fix it?
This is how I went about it for Klint with Kotlin DSL on
gradle.kts
files for Android Gradle. Have also added Spotless with Kotlin DSL ( code formatter ) at the same time.It is also worth noting mine is NOT a Multi Module project.
Step 1 - gradle.kts (app) - Add Klint and Spotless plugins and import
Reporters
Step 2 - gradle.kts (app) - Configure Klint only
Step 3 - gradle.kts(app) - Configure Spotless only
Step 4 - gradle.kts(project) - Add Spotless in the Classpath
The 2 plugins works fine with this set-up.