I'm new to Spotless and ktlint, trying to add it to my projects. Basic configuration is simple enough, however I want to allow wildcard imports, a topic which comes up quite regularly. However, I can't seem to make it work with my current config:
plugins {
id("com.android.application") version "8.1.4" apply false
id("org.jetbrains.kotlin.android") version "1.9.10" apply false
id("com.google.dagger.hilt.android") version "2.48.1" apply false
id("com.google.devtools.ksp") version "1.9.10-1.0.13" apply false
id("com.diffplug.spotless") version "6.19.0" apply false
}
subprojects {
apply(plugin = "com.diffplug.spotless")
configure<com.diffplug.gradle.spotless.SpotlessExtension> {
kotlin {
target("**/*.kt")
ktlint().setEditorConfigPath("$projectDir/../.editorconfig")
targetExclude("$buildDir/**/*.kt")
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
}
kotlinGradle {
target("*.gradle.kts")
ktlint()
}
}
afterEvaluate {
tasks.named("preBuild") {
dependsOn("spotlessApply")
}
}
}
within my editor config file:
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false
[*.{java,kt,kts,xml}]
indent_size = 4
max_line_length = 200
[*.{kt,kts}]
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
ij_kotlin_packages_to_use_import_on_demand = disabled
I've tried disabled, false, unset, but none of these work, I'll always get an error:
Error on line: 3, column: 1
rule: standard:no-wildcard-imports
Wildcard import
What am I doing wrong here ? Is this simply impossible to do ?