Skip to content

[MNG-7793] Add generated-source metadata to Maven 4 APIs - #12958

Merged
gnodet merged 1 commit into
apache:masterfrom
goutamadwant:feature/mng-7793-generated-source-metadata
Sep 7, 2026
Merged

[MNG-7793] Add generated-source metadata to Maven 4 APIs#12958
gnodet merged 1 commit into
apache:masterfrom
goutamadwant:feature/mng-7793-generated-source-metadata

Conversation

@goutamadwant

@goutamadwant goutamadwant commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #9196

Summary

Add explicit generated-source metadata to Maven 4's source model and APIs so plugins can distinguish generated files without relying on directory naming conventions.

Implementation

  • Add the generated attribute to org.apache.maven.api.model.Source.
  • Expose generated state through SourceRoot.
  • Add explicit generated-source registration through ProjectManager.
  • Preserve the value through model XML, consumer POM, and legacy resource adapter paths.
  • Keep existing and legacy source registration defaulting to non-generated.
  • Preserve first-registration-wins behavior for duplicate source roots.

Verification

  • mvn --batch-mode verify
  • Focused API, implementation, and core module verification
  • XML round-trip and consumer POM coverage
  • Generated registration, duplicate registration, and legacy resource mutation coverage

Following this checklist to help us incorporate your contribution quickly and easily:

  • This pull request addresses one issue without unrelated changes.
  • The description explains what the change does, how, and why.
  • The commit has a meaningful subject and DCO sign-off.
  • Unit tests cover the behavioral changes.
  • mvn verify passes.
  • The Core IT suite has been run successfully.
  • I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
  • In any other case, please file an Apache Individual Contributor License Agreement.

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to target Maven 4.1.0, hence the model version 4.2.0.

@goutamadwant

Copy link
Copy Markdown
Contributor Author

Thanks @gnodet. Updated the generated field to target model version 4.2.0 and moved the corresponding XML round-trip and consumer POM coverage to the 4.2.0 namespace. Let me know if this looks good now.

@slachiewicz

Copy link
Copy Markdown
Member

One more thing to address, please rebase and squash commits

@gnodet gnodet added this to the 4.1.0 milestone Aug 31, 2026
Signed-off-by: goutamadwant <workwithgoutam@gmail.com>
@goutamadwant
goutamadwant force-pushed the feature/mng-7793-generated-source-metadata branch from 496cca0 to 3bf6edd Compare September 1, 2026 03:08
@goutamadwant

goutamadwant commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

@slachiewicz Rebased onto the latest master and squashed the changes into a single signed commit. Thanks for the review.!

@gnodet
gnodet self-requested a review September 1, 2026 11:19
@gnodet gnodet added the enhancement New feature or request label Sep 2, 2026
gnodet added a commit to gnodet/maven that referenced this pull request Sep 2, 2026
gnodet added a commit to gnodet/maven that referenced this pull request Sep 2, 2026

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generated attribute is properly threaded through all layers — model (4.2.0+), API (SourceRoot.generated()), service (ProjectManager.addSourceRoot overload), implementation (DefaultSourceRoot, DefaultProjectManager, ConnectedResource), and serialization (XML round-trip, consumer POM).

Backward compatibility is maintained via the bridging constructor that defaults generated to false. The duplicate-check logic in DefaultProjectManager.addSourceRoot correctly uses scope+language+directory as the key (excluding generated), preserving first-registration-wins semantics. Tests cover all the interesting cases: generated registration, duplicate handling, legacy non-generated default, resource mutation preservation, and XML round-trip in the 4.2.0 namespace.

The model version targeting (4.2.0+) addresses the earlier review feedback.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet
gnodet merged commit 3f6be6d into apache:master Sep 7, 2026
22 checks passed
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

None yet

Development

Successfully merging this pull request may close these issues.

[MNG-7793] Add APIs for generated sources

3 participants