Skip to content

Fix modello velocity phase for concurrent builder compatibility - #12687

Open
gnodet wants to merge 1 commit into
masterfrom
fix/modello-velocity-generate-sources
Open

Fix modello velocity phase for concurrent builder compatibility#12687
gnodet wants to merge 1 commit into
masterfrom
fix/modello-velocity-generate-sources

Conversation

@gnodet

@gnodet gnodet commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 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
  • Aligns with the pattern already used by maven-api-model

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):

phase(BUILD,
    phase(SOURCES),
    phase(RESOURCES),                                            ← parallel with SOURCES
    phase(COMPILE, after(SOURCES), dependencies(..., READY)),    ← waits for SOURCES, not RESOURCES
    phase(READY, after(COMPILE), after(RESOURCES)),
    phase(PACKAGE, after(READY), ...))

The modello velocity goal generates Java source files, but was bound to generate-resources (→ RESOURCES phase). This created a race: COMPILE could start while velocity was still running, missing the generated sources.

The race manifested deterministically as mvn build -T1C -b concurrent failing without clean (upstream incremental builds finished fast → COMPILE started before modello), while mvn clean build -T1C -b concurrent worked (upstream full rebuilds took longer → modello finished first).

Test plan

  • mvn clean build -T1C -b concurrent -DskipTests → BUILD SUCCESS
  • mvn build -T1C -b concurrent -DskipTests (without clean) → BUILD SUCCESS (previously failed with package org.apache.maven.api.settings does not exist)

🤖 Generated with Claude Code

…ilder compatibility

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.

LGTM. Correct and minimal fix for a real concurrency race condition in the Maven 4 concurrent builder.

The lifecycle definition confirms the issue: SOURCES and RESOURCES are parallel siblings under BUILD, and COMPILE has after(SOURCES) but no dependency on RESOURCES. Moving the velocity goal from generate-resources (RESOURCES phase) to generate-sources (SOURCES phase) ensures COMPILE waits for the generated Java files.

Verified that all other modules in the repository already use generate-sources for the velocity goal — maven-api-settings and maven-api-toolchain were the only two holdouts. The execution ID scheme is clean: existing modello ID retained for velocity, new modello-docs ID for xdoc/xsd. Plugin-level configuration is correctly inherited by both executions.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of gnodet

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