Skip to content

[Backport 4.0.x] Fix modello velocity phase for concurrent builder compatibility - #12963

Merged
gnodet merged 1 commit into
maven-4.0.xfrom
backport/12687-to-maven-4.0.x
Aug 31, 2026
Merged

gnodet merged 1 commit into
maven-4.0.xfrom
backport/12687-to-maven-4.0.x

Conversation

@gnodet

@gnodet gnodet commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Backport of #12687 to maven-4.0.x.

  • Split modello plugin executions in maven-api-settings and maven-api-toolchain so the velocity goal (Java source generation) runs at generate-sources instead of generate-resources, while xdoc/xsd (documentation) remain at generate-resources
  • Fixes a race condition in the concurrent builder (-b concurrent) where COMPILE could start before velocity finished generating Java source files, causing "package does not exist" compilation errors

Details

In Maven 4's graph lifecycle model, SOURCES and RESOURCES are parallel siblings under BUILD, and COMPILE is ordered after(SOURCES) but not after(RESOURCES). The modello velocity goal generates Java source files but was bound to generate-resources (→ RESOURCES phase), creating a race where COMPILE could start before source generation finished.

Cherry-picked cleanly from master (852e66a).

Test plan

  • CI passes on maven-4.0.x

🤖 Generated with Claude Code

…ilder compatibility (#12687)

In the Maven 4 graph lifecycle model, the SOURCES and RESOURCES phases
are parallel siblings under BUILD, and COMPILE depends on SOURCES
(via after(SOURCES)) but not on RESOURCES. The modello velocity goal
generates Java source files, but was bound to generate-resources
(mapped to the RESOURCES phase), creating a race condition with the
concurrent builder (-b concurrent): COMPILE could start before
the velocity goal finished generating Java sources.

This caused "package does not exist" compilation errors when running
`mvn build -T1C -b concurrent` without clean, because upstream
modules built fast enough (incremental) that COMPILE started before
modello had called addCompileSourceRoot(). With clean, upstream
rebuilds took longer, masking the race.

Split the modello execution so velocity (Java source generation) runs
at generate-sources (SOURCES phase) and xdoc/xsd (documentation)
stay at generate-resources (RESOURCES phase), matching the pattern
already used by maven-api-model.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

✅ Looks Good

Clean backport of #12687 (master → maven-4.0.x). The cherry-pick is byte-identical to the original commit (852e66a), targets exactly the two modules with the race condition, and the fix is semantically sound — velocity generates Java sources so it belongs at generate-sources, while xdoc/xsd generate documentation resources and correctly stay at generate-resources.

Verification notes:

  • Checked all modello-using modules on maven-4.0.x: only maven-api-settings and maven-api-toolchain had velocity bound to generate-resources; all other modules (maven-api-cli, maven-api-metadata, maven-api-model, maven-api-plugin, compat modules) already use generate-sources. The fix is complete.
  • The new execution ID modello-docs is clear, descriptive, and does not conflict with any existing execution ID in these modules.
  • No backport to 3.x branches is needed — the concurrent builder's graph lifecycle model (parallel SOURCES/RESOURCES phases) is Maven 4-only.

📋 PR Metadata

Aspect Current Suggested
Labels (none) bug
Milestone (none) 4.0.0-rc-7

🤖 This review was generated by ForgeBot.

@gnodet gnodet added this to the 4.0.0-rc-7 milestone Aug 31, 2026
@gnodet gnodet added bug Something isn't working mvn40 backport labels Aug 31, 2026
@gnodet
gnodet merged commit 18f7980 into maven-4.0.x Aug 31, 2026
24 checks passed
@gnodet
gnodet deleted the backport/12687-to-maven-4.0.x branch August 31, 2026 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport bug Something isn't working mvn40

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant