Skip parsing generated sources; use compiled classes instead by timtebeek · Pull Request #1142 · openrewrite/rewrite-maven-plugin (original) (raw)
…nstead
Generated sources under the build directory (e.g. target/generated-sources/) were being fully parsed into LSTs only to be filtered out afterward. Since getCompileClasspathElements() already includes target/classes with the compiled .class files for these sources, type attribution works without parsing them.
This adds filterGeneratedSourceRoots() to exclude source roots under the build directory before scanning for source files, avoiding unnecessary parsing work for projects that heavily use code generation (protobuf, MapStruct, annotation processors, etc.).
Closes #667
Restore unfiltered source roots for parsedPaths pre-population so that OmniParser does not pick up generated .java files as PlainText. The filtering of generated source roots is still applied in processMainSources and processTestSources to skip expensive language parsing, and the buildDirectory filter at the end acts as a safety net.
Move the build directory filter from processMainSources/processTestSources into the unified isExcluded check, matching the Gradle plugin's approach. Generated sources are now excluded in one place alongside user exclusions and gitignore checks, while filterGeneratedSourceRoots still skips expensive language parsing upfront.
…unchanged
Move the buildDirectory exclusion out of isExcluded and into the call site at L241 as an inline check, keeping isExcluded's signature and tests unchanged. Remove build directory unit tests that no longer apply to isExcluded directly.
timtebeek deleted the tim/generated-sources-classpath branch
mergify Bot added a commit to robfrank/linklift that referenced this pull request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})