Skip to content

Conversation

timtebeek
Copy link
Member

@timtebeek timtebeek commented Aug 25, 2025

Summary

This PR adds support for multiple main source folders, mirroring the functionality added for test source folders in PR #888.

Motivation

Maven projects using build-helper-maven-plugin or similar tools to configure additional source directories (e.g., for generated code, integration modules, or multi-source projects) need the rewrite-maven-plugin to process all configured main source directories, not just the default src/main/java.

Changes

  • Modified MavenMojoProjectParser.processMainSources() to iterate through all compile source roots using mavenProject.getCompileSourceRoots() instead of only processing the single default source directory
  • Updated both Java and Kotlin source collection to handle multiple source directories
  • Added integration test multi_main_source_sets_project to verify recipes are applied to files in all configured main source directories

Testing

  • Added new integration test that configures an additional main source directory using build-helper-maven-plugin
  • Test verifies that the SingleLineComments recipe is applied to Java files in both:
    • src/main/java
    • src/additional-main/java
  • All existing tests pass

Related

  • Follows the same implementation pattern as PR Add tests for multi source sets #888 which added support for multiple test source folders
  • Resolves the need for symmetric functionality between main and test source processing

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

Similar to the support for additional test source folders added in PR #888,
this change enables the rewrite-maven-plugin to process multiple main source
directories configured via build-helper-maven-plugin or similar tools.

Changes:
- Modified MavenMojoProjectParser to iterate through all compile source roots
  using mavenProject.getCompileSourceRoots() instead of single source directory
- Added integration test to verify recipes are applied to files in all main
  source directories
- Follows the same pattern as the existing test source folder implementation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@timtebeek timtebeek added the enhancement New feature or request label Aug 25, 2025
timtebeek and others added 2 commits August 25, 2025 10:59
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@timtebeek timtebeek marked this pull request as draft August 26, 2025 19:31
@timtebeek
Copy link
Member Author

Likely fixed in

@timtebeek timtebeek marked this pull request as ready for review October 10, 2025 14:13
@timtebeek timtebeek changed the title Add support for multiple main source folders Verify support for multiple main source folders Oct 10, 2025
@timtebeek timtebeek merged commit 199dc0c into main Oct 10, 2025
2 checks passed
@timtebeek timtebeek deleted the additional-main-source-paths branch October 10, 2025 14:13
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Sources added by build-helper-maven-plugin are ignored

1 participant