Skip to content

Conversation

DanielLiu1123
Copy link

  • Add JavaFileMerger class for standalone Java file merging using JavaParser
  • Modify DefaultShellCallback to support Java file merging by default
  • Support merging based on @mbg.generated JavaDoc tags and @Generated annotations (javax/jakarta)
  • Preserve custom methods while updating generated methods
  • Update JavaParser dependency scope to make it available for main code

This enables automatic merging of Java Mapper files during regeneration, similar to the existing XML merge functionality.

Close #595

- Add JavaFileMergerJavaParser class for standalone Java file merging using JavaParser
- Modify DefaultShellCallback to support Java file merging by default
- Support merging based on @mbg.generated JavaDoc tags and @generated annotations (javax/jakarta)
- Preserve custom methods while updating generated methods
- Add comprehensive tests and demo for the merge functionality
- Update JavaParser dependency scope to make it available for main code

This enables automatic merging of Java Mapper files during regeneration,
similar to the existing XML merge functionality.
…ctices

- Rewrite mergeImports method to sort imports according to Java best practices:
  1. java.* packages (alphabetically)
  2. javax.* packages (alphabetically)
  3. jakarta.* packages (alphabetically)
  4. Third-party and project packages (alphabetically)
  5. Static imports (alphabetically, at the end)
- Add ImportInfo helper class to handle import deduplication and comparison
- Implement compareImports method with proper priority-based sorting
- Update existing test expectations to match new sorted import order
- Add comprehensive test shouldSortImportsAccordingToBestPractices to verify:
  * Correct ordering of different package types
  * Proper handling of static imports
  * Alphabetical sorting within each category
- All 10 tests pass successfully
- Import output is now predictable and follows industry standards
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

java file merge
1 participant