openrewrite / rewrite-maven-plugin

OpenRewrite's Maven plugin.
https://openrewrite.github.io/rewrite-maven-plugin/plugin-info.html
Apache License 2.0
143 stars 74 forks source link

Add tests for multi source sets #888

Closed nielsdebruin closed 2 weeks ago

nielsdebruin commented 2 weeks ago

What's changed?

This PR adds support and test cases for running recipes on test source files located outside the standard maven test sources directory src/test/java for example src/integration-test/java.

Important: The PR showed a bug with our current integration testing method for the Maven plugin. This causes the test cases that have been added to fail, even though manual testing of the plugin by myself and @timtebeek showed it works as desired. For this reason, the added tests have currently been disabled.

What's your motivation?

Currently, recipes that do not rely on classpath resources, e.g., rewriting a boolean expression, will still work. However, recipes that rely on classpath resources such as FindTypes will not work.

Checklist

timtebeek commented 2 weeks ago

I noticed that in Maven Core the build source directories are added to the project source roots as well; https://github.com/apache/maven/blob/f8cba5dc2717230a17c9589efe111d8dd0c1abbf/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java#L576-L582

Are we sure we need to separately add those build source directories here? Or can we rely on the above?