Closed timtebeek closed 3 months ago
I suspect that we're actually including all types of generated sources that are produced by various plugins as they will appear within the source files from sourceSet.getAllSources()
. I think the current proto implementation was a bandaid around the problem, but never actually addressed it.
What should probably be being done is a filter operation when collecting all of the unparsed sources and excluding them when they are contained within subproject.getLayout().getBuildDirectory()
(already confirmed that this is also available on the baseline Gradle 4.10, so no special logic is required for old versions). This would be directly akin to what was done within the Maven plugin.
Thanks for the hint! Noticed we only had that pattern for Java; now also for Kotlin & Groovy + Kotlin multi platform. Should help I think, although it's a bit cumbersome to test.
What's changed?
Reuse the mechanism we added for
protos/build/generated
forbuild/generated-sources
.What's your motivation?
Files like
build-src/build/generated-sources
are parsed into the LST, and modified by recipes. That last part is undesirable, as the diffs would then target files not part of the git repository, and fail to apply from a dryRun fix.patch file.Anything in particular you'd like reviewers to focus on?
There's likely a better way, but I'm having a bit of trouble working that out. Figured open this PR to start the discussion.
Have you considered any alternatives or workarounds?
What I'd done previously in an attempt to exclude these files is add them to Git ignore: https://github.com/openrewrite/rewrite-recipe-bom/commit/9f5840cc1d8d8b4f4795546b95c8242622d6c116 But somehow they are still picked up; I had thought we already excluded files ignored in git.
Any additional context
I know in the Maven plugin we explicitly exclude generated sources, but I'm not immediately seeing an equivalent here. https://github.com/ammachado/rewrite-maven-plugin/blob/f900a9a6365a4d02c0083dd29e14927d6ffa6576/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java#L425-L430