hello! I'm writing a custom Gradle plugin that gen...
# ktlint
d
hello! I'm writing a custom Gradle plugin that generates source files and was wondering if there is a way I could automatically exclude them from ktlint check?, e.g. I'm using
org.jlleitschuh.gradle.ktlint
which automatically applies the linter against all source sets. Currently I'm manually configuring
ktlint
task to filter out
generated
sources but was wondering whether there is some better way?
Copy code
tasks {
    ktlint {
        filter {
            exclude("**/generated/**")
        }
    }
}
e.g. above approach is not ideal as anyone using the plugin will have to add that configuration as well
t
you could configure this via your plugin
something like
extensions.configure(KtlintExtension::class.java) { filter { exclude(..) }}
d
guess would have to conditionally check if ktlint is applied
but yeah probably should do that
t
you could wrap it in
plugins.withId("org.jlleitschuh.gradle.ktlint") { // configure extension here }
d
Hmm in order to configure the extension I'd have to add it to plugin dependencies. Unsure if I want to do it
m
You could certainly make it a compileOnly dependency ?
1