Skip to content

Conversation

@sbafsk
Copy link
Collaborator

@sbafsk sbafsk commented Dec 1, 2025

Summary

Fix critical Maven POM configuration issues that could cause compilation failures when using Lombok and MapStruct together. These changes ensure proper annotation processing order and add missing dependencies for compatibility.

Changes Made

🔧 Dependencies

  • ✅ Add explicit <packaging>jar</packaging> declaration for clarity
  • ✅ Add lombok.version property (1.18.30) for version consistency
  • Add lombok-mapstruct-binding dependency (0.2.0) - Critical for Lombok+MapStruct compatibility
  • ✅ Add spring-security-test dependency for security testing support

⚙️ Compiler Configuration

  • ✅ Replace deprecated <source>21</source> and <target>21</target> with modern <release>${java.version}</release>
  • ✅ Add lombok-mapstruct-binding to annotation processor path with correct order:
    1. Lombok → generates getters/setters/builders
    2. Lombok-MapStruct binding → bridges both libraries
    3. MapStruct processor → uses Lombok-generated code

Why These Changes Matter

🚨 Critical Fix: lombok-mapstruct-binding

Without this binding, MapStruct cannot properly process Lombok-annotated classes. This causes compilation errors when generating mappers for entities using @Data, @Builder, @Getter, etc.

📋 Annotation Processor Order

The processing order is crucial:

  • Lombok must run first to generate code
  • The binding bridges the two libraries
  • MapStruct runs last to use the Lombok-generated code

🎯 Modern Java Compilation

Using <release> instead of <source>/<target> is the recommended approach since Java 9, providing better cross-compilation guarantees and ensuring bytecode compatibility.

Testing Checklist

  • Verify Maven build completes successfully: mvn clean compile
  • Verify no compilation errors with Lombok+MapStruct entities
  • Verify MapStruct mappers generate correctly
  • Verify annotation processors run in correct order

References

🤖 Generated with Claude Code

…bility

Fix critical configuration issues in pom.xml that could cause compilation failures when using Lombok and MapStruct together.

## Changes

### Dependencies
- Add explicit `<packaging>jar</packaging>` declaration
- Add `lombok.version` property for consistency (1.18.30)
- Add `lombok-mapstruct-binding` dependency (0.2.0) - **Critical for Lombok+MapStruct compatibility**
- Add `spring-security-test` dependency for security testing support

### Compiler Configuration
- Replace `<source>` and `<target>` with `<release>${java.version}` (modern Java 9+ approach)
- Add `lombok-mapstruct-binding` to annotation processor path with correct order:
  1. Lombok (generates code)
  2. Lombok-MapStruct binding (bridges both libraries)
  3. MapStruct processor (uses Lombok-generated code)

## Why These Changes Matter

**lombok-mapstruct-binding**: Without this binding, MapStruct cannot properly process Lombok-annotated classes, leading to compilation errors when generating mappers for entities with @DaTa, @builder, etc.

**Annotation processor order**: The order matters - Lombok must run first to generate getters/setters, then the binding bridges them, and finally MapStruct can use the generated code.

**Release vs Source/Target**: Using `<release>` is the recommended approach since Java 9, providing better cross-compilation guarantees.

## References
- Maven POM Best Practices: https://maven.apache.org/guides/introduction/introduction-to-the-pom.html
- Lombok-MapStruct Integration: https://mapstruct.org/faq/#can-i-use-mapstruct-together-with-project-lombok

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

Co-Authored-By: Claude <noreply@anthropic.com>
@sbafsk sbafsk merged commit a350f5b into main Dec 1, 2025
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.

2 participants