Fix modello velocity phase for concurrent builder compatibility - #12687
Fix modello velocity phase for concurrent builder compatibility#12687gnodet wants to merge 1 commit into
Conversation
…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
left a comment
There was a problem hiding this comment.
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
Summary
maven-api-settingsandmaven-api-toolchainso thevelocitygoal (Java source generation) runs atgenerate-sourcesinstead ofgenerate-resources, whilexdoc/xsd(documentation) remain atgenerate-resources-b concurrent) whereCOMPILEcould start beforevelocityfinished generating Java source files, causing"package does not exist"compilation errorsmaven-api-modelDetails
In Maven 4's graph lifecycle model,
SOURCESandRESOURCESare parallel siblings underBUILD, andCOMPILEis orderedafter(SOURCES)but notafter(RESOURCES):The modello
velocitygoal generates Java source files, but was bound togenerate-resources(→RESOURCESphase). This created a race:COMPILEcould start whilevelocitywas still running, missing the generated sources.The race manifested deterministically as
mvn build -T1C -b concurrentfailing withoutclean(upstream incremental builds finished fast →COMPILEstarted before modello), whilemvn clean build -T1C -b concurrentworked (upstream full rebuilds took longer → modello finished first).Test plan
mvn clean build -T1C -b concurrent -DskipTests→ BUILD SUCCESSmvn build -T1C -b concurrent -DskipTests(without clean) → BUILD SUCCESS (previously failed withpackage org.apache.maven.api.settings does not exist)🤖 Generated with Claude Code