How linpeilie/mapstruct-plus works
Project Type and Purpose
• This is a multi‑module Java library and toolset (Maven-based) that enhances MapStruct, providing annotation-driven automatic object mapping.
• Core modules:
• mapstruct‑plus (runtime library containing Converter, ConverterFactory, utilities, base classes)
• mapstruct‑plus‑processor (compile‑time annotation processor that scans @AutoMapper, generates mapper code)
• mapstruct‑plus‑spring‑boot‑starter (Spring Boot auto‑configuration, registers Converter bean)
• mapstruct‑plus‑object‑convert (convenience wrapper for direct object conversion)
• Supporting modules: docs (VuePress site), example projects demonstrating usage, CI/CD workflows under .github.
File‑Structure Analysis
• Top level: parent pom.xml, module directories, .github workflows, docs folder for site generation, example folder for sample apps.
• Each module contains its own pom.xml and src tree.
• build logic: Maven multi‑module aggregator; annotationProcessorPaths defined in examples to include mapstruct‑plus‑processor.
• Configuration files for docs (VuePress) and GitHub Actions for issue management, docs deployment, release.
Key README Insights
• Describes MapStruct Plus goal: minimal, powerful type conversion via @AutoMapper annotations.
• Quick‑start shows adding mapstruct‑plus‑spring‑boot‑starter and mapstruct‑plus‑processor to Maven compiler plugin.
• Developer workflow: annotate classes, compile (processor generates mapping code), at runtime inject Converter and call convert().
a. Main Components
• User Application Code
• Annotation Processor (mapstruct‑plus‑processor)
• Generated Mapper Classes
• Core Runtime Library (mapstruct‑plus)
• Spring Boot Starter (mapstruct‑plus‑spring‑boot‑starter)
• Converter Facade (mapstruct‑plus‑object‑convert)
• External: MapStruct core, Spring Context, Maven Compiler Plugin
b. Relationships and Data Flows
1. User code annotated with @AutoMapper → during “mvn compile”
→ mapstruct‑plus‑processor reads annotations → generates mapper source files.
2. Generated mappers depend on core library APIs (ConverterFactory, BaseMapper).
3. At runtime, Spring Boot Starter auto‑configures Converter bean → wires in generated mappers via ConverterFactory.
4. Application invokes converter.convert(source, Target.class) → core library uses generated mapper methods → returns target instance.
5. mapstruct‑plus‑object‑convert provides static helper MapObjectConvert for non‑Spring environments.
c. Architectural Patterns & Principles
• Compile‑time code generation (annotation processing)
• Inversion of Control / Dependency Injection (Spring Starter)
• Separation of concerns:
– Processor module handles generation
– Core module handles runtime conversion logic
– Starter module handles framework integration
• Maven multi‑module structure for clear modular boundaries
d. Technologies & Frameworks
• Java Annotation Processing API (javax.annotation.processing)
• Maven Compiler Plugin
• Spring Boot Auto‑Configuration
• VuePress for documentation
• GitHub Actions for CI/CD