Open pkubowicz opened 10 months ago
Can you share a build scan?
Also, a minor reproducer would be nice.
@wakingrufus we could probably automatically filter out this directory when the kotlin-dsl plugin is applied. Thoughts?
The scan is here: https://scans.gradle.com/s/enzehbyek47qs
Attached a simple reproducer. gradle-kotlin-buildsrc.zip
Can you share a build scan?
Also, a minor reproducer would be nice.
@wakingrufus we could probably automatically filter out this directory when the kotlin-dsl plugin is applied. Thoughts?
We could. I don't see this problem in regular projects using the kotlin-dsl plugin, so what is different about buildSrc that causes this?
tl;dr: It looks like something is getting cached in buildSrc/.gradle/buildOutputCleanup/
that's preventing changes to excludes from being honored.
I ran into this same problem: ktlint was reporting errors in the Kotlin code that Gradle generates in buildSrc/
. I added an exclude like this...
ktlint {
filter {
exclude {
it.file.relativeTo(projectDir).startsWith(File("build"))
}
}
}
...and it continued reporting these errors. Eventually I used git clean
to delete all ignored files from my repo, and then it started working.
I was able to narrow the problem down to buildSrc/.gradle/buildOutputCleanup/
by conducting the following series of tests:
rm -rf buildSrc/.gradle/
: WORKSrm -rf buildSrc/.gradle/kotlin/
: FAILSrm -rf buildSrc/.gradle/buildOutputCleanup/
: WORKSrm -rf buildSrc/.gradle/buildOutputCleanup/
: WORKS"WORKS" and "FAILS" indicate the outcome of running ./gradlew :buildSrc:ktlintCheck
after the corresponding operation.
When I add the plugin to buildSrc/build.gradle.kts:
it fails on classes generated by Gradle, even though I explicitly instruct the plugin not to include them.