Hi team, I'm using the spotless plugin in my grad...
# server
r
Hi team, I'm using the spotless plugin in my gradle kotlin project. I have used the ktlint and diktat from the spotless. I have a situation where I need to avoid running the diktat for test files , but run only for src files. But for ktlint, it has to run on both src and test files. I have made the below configuration in my build.gradle.kts , but seems like both ktlint & diktat is not happening for test files. (I want only ktlint to run for the test files)
Copy code
spotless {
 kotlin { 
    ktlint().apply {
     target("src/main/kotlin/**/*.kt") editorConfigOverride( 
mapOf( "ij_kotlin_allow_trailing_comma" to "true", "ij_kotlin_allow_trailing_comma_on_call_site" to "true", "ktlint_function_naming_ignore_when_annotated_with" to "Composable" )
 ) 
}
 diktat().apply {
 configFile("./../diktat-analysis.yml") targetExclude("src/test/kotlin/**/*.kt")
 } 
} 
kotlinGradle {
 diktat().configFile("./../diktat-analysis.yml") } 
}
WE can clearly see that I have a targetExclude just for diktat(). Can anyone help me here please ? Am I missing something ?
p
Your (include) target on ktlint chechs in
main
only. It looks like that you need
test
as well
r
Sorry @Paul Dingemans, I have updated the wrong code here. I added there for test aswell. like this
target("src/main/kotlin/**/*.kt","src/test/kotlin/**/*.kt")
still ktlint didnt work for tests .
p
The problem is more in the Spotless integration than in ktlint itself. I know all about ktlint, but I am not familiar how Spotless integration works. Maybe you can reach out directly to Spotless project?
r
Yeah, Thanks. Opened an discussion there