Add generated-source metadata to Maven 4 APIs
Introduced first-class generated-source metadata across Maven 4's model, public source-root APIs, project services, serialization paths, and legacy adapters.
apache/maven · #12958
Build-platform API feature
Maven plugins can now identify generated source roots explicitly instead of inferring them from nonstandard directory names.
Problem
Static-analysis and source-processing plugins need to distinguish generated code, but generated roots are not required to live under a conventional directory. Maven exposed source paths without durable metadata, forcing plugins to guess from location or maintain separate lists.
Approach
Adds the versioned `generated` model attribute, exposes it through `SourceRoot`, and provides explicit registration through `ProjectManager`. The value survives model XML, consumer POM, and legacy resource adaptation while existing registration remains non-generated by default.
Impact and scope
- Gives Checkstyle, PMD, and other plugins a reliable API signal for excluding or handling generated code.
- Carries one source classification consistently across Maven's model, API, service, implementation, and serialization boundaries.
- Maintains compatibility through false-by-default bridges and preserves first-registration-wins behavior for duplicate roots.
Validation
- Added generated registration, duplicate handling, legacy-default, resource-mutation, model XML round-trip, and consumer POM coverage.
- Focused API, implementation, and core verification, the Maven Core integration-test suite, and full `mvn verify` passed; no final PR check reported a failure.
- A Maven maintainer approved the revised 4.2.0 model targeting; the GitHub-verified merge commit credits Goutam Adwant and closed MNG-7793.