rewrite-maven-plugin icon indicating copy to clipboard operation
rewrite-maven-plugin copied to clipboard

Do not parse generated sources as source files, but only as compiled classes

Open timtebeek opened this issue 2 years ago • 1 comments

As identified on

  • https://github.com/openrewrite/rewrite-maven-plugin/pull/665#discussion_r1405340228

I think it boils down to the question if getCompileClasspathElements() returns the classes compiled fom generated sources as well, which could depend on a number of different factors depending on how the code generation is configured. https://github.com/openrewrite/rewrite-maven-plugin/blob/0b8fc330f355a96b6e5b7a103601c07f775d9de3/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java#L317-L324

Right now we define generated sources as anything we find in the target/ directory, and parse those as source. https://github.com/openrewrite/rewrite-maven-plugin/blob/0b8fc330f355a96b6e5b7a103601c07f775d9de3/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java#L302-L308

Before we then later filter out those generated sources. https://github.com/openrewrite/rewrite-maven-plugin/blob/9a9428fbd211b79cebdec18a68b830e16434ade3/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java#L341-L346

It might be interesting to not parse those generated sources as source files but rather only as classpath entries. I'm not entirely sure that would work in all cases, but it could speed up builds for projects that heavily use generated sources.

timtebeek avatar Nov 28 '23 10:11 timtebeek