ktlint-gradle icon indicating copy to clipboard operation
ktlint-gradle copied to clipboard

Filter to exclude a generated dir is not working in version 12.1.0

Open edpichler opened this issue 1 year ago • 4 comments

The filter is not working in version 12.1.0 under Windows using the following configuration:

configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
    filter {
        exclude("**/generated/**")
    }
}

Below is how to workaround the problem:

configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
   filter {
        exclude { element -> 
            val path = element.file.path
            path.contains("\\generated\\") || path.contains("/generated/") 
        }
    }
}

I haven't tested it but it seems the problem is related to the / when different platforms.

edpichler avatar Feb 24 '24 22:02 edpichler

it doesn't seem to be reliably working... I'm using the latest kotlin multiplatform which is generating own Resources... no matter of exclude result, the ktlint fails as it's not following predefined rules

jbruchanov avatar Mar 17 '24 22:03 jbruchanov

it doesn't seem to be reliably working

Perhaps this is why.

xenomachina avatar Apr 10 '24 23:04 xenomachina

I was having the same problem on 12.1.0 with any combination, moved to 12.1.1 using the config below and was solved:

configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
    enableExperimentalRules.set(true)
    filter {
        exclude { element ->
            val path = element.file.path
            path.contains("\\generated\\") || path.contains("/generated/")
        }
    }
}

brahyam avatar May 15 '24 09:05 brahyam