Skip to content

Commit

Permalink
Swap to ktfmt (googleStyle), but keep ktlint for gradle scripts…
Browse files Browse the repository at this point in the history
… (#233)

Seems like this is the way to go...?

Related: will-molloy/java-template#245
GitOrigin-RevId: 65b15a6b34bff8a4072558e718b2ed055c44ecf6
  • Loading branch information
will-molloy committed Jan 6, 2025
1 parent f45b46d commit 87b5eac
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,19 @@ allprojects {

apply(plugin = "com.diffplug.spotless")
configure<SpotlessExtension> {
// https://github.com/diffplug/spotless/tree/main/plugin-gradle#java
java {
removeUnusedImports()
googleJavaFormat()
trimTrailingWhitespace()
endWithNewline()
}
// https://github.com/diffplug/spotless/tree/main/plugin-gradle#kotlin
// Compared to ktlint, it seems ktfmt is better for actual Kotlin code (more deterministic/consistent output).
// Furthermore, spotless is more for formatting than linting.
// However, it has some weird output with Gradle scripts, so using ktlint for that.
kotlin {
ktlint().editorConfigOverride(mapOf("ktlint_standard_package-name" to "disabled"))
ktfmt().googleStyle()
trimTrailingWhitespace()
endWithNewline()
}
Expand All @@ -55,7 +60,7 @@ allprojects {
}
}

// TODO detekt for kotlin
// TODO Kotlin alternative?
apply(plugin = "checkstyle")
configure<CheckstyleExtension> {
toolVersion = "10.12.0"
Expand Down

0 comments on commit 87b5eac

Please sign in to comment.