gnodet commented on PR #12653:
URL: https://github.com/apache/maven/pull/12653#issuecomment-5153602282

   ## New commit: Store single model-object fields as sub-builders
   
   Added commit `4ade9fe` that extends the deferred-build pattern from 
list-of-model-object fields to **single model-object fields** (multiplicity=1).
   
   ### What changed
   
   **model.vm — single model-object fields now use sub-builders:**
   
   Builder classes now store fields like `Build`, `Reporting`, 
`DependencyManagement`, `Parent`, `Scm`, `Organization`, `Prerequisites`, 
`IssueManagement`, `CiManagement`, `DistributionManagement`, 
`PluginManagement`, `Activation`, `ActivationOS`, `ActivationFile`, 
`ActivationProperty`, `BuildBase`, `Relocation`, `Site`, 
`DeploymentRepository`, `RepositoryPolicy` as `X.Builder` instead of immutable 
`X`. This means:
   
   | Before | After |
   |--------|-------|
   | `Build build;` in Builder | `Build.Builder build;` in Builder |
   | Setter stores immutable directly | Setter wraps: `X.newBuilder(val, 
false)` |
   | Getter returns field directly | Getter calls `.build()` on sub-builder |
   | No mutable access | New `getModifiable*()` returns `X.Builder` |
   | `build()` short-circuit: identity check | `build()` short-circuit: null 
check |
   | forceCopy copies immutable ref | forceCopy wraps into sub-builder |
   
   **Pipeline stages updated to use `getModifiable*()`:**
   
   - **DefaultModelPathTranslator**: mutates `Build.Builder` / 
`Reporting.Builder` sub-builders in place — eliminates 
`Build.newBuilder(build).xyz().build()` intermediate allocations (10+ field 
mutations per call)
   - **DefaultModelNormalizer**: sets deduplicated plugins directly on 
`Build.Builder` via `getModifiableBuild().plugins(...)` 
   - **DefaultPluginConfigurationExpander**: mutates `Build.Builder` and nested 
`PluginManagement.Builder` sub-builders in place
   - **DefaultPluginManagementInjector**: extracts merged plugin list and sets 
it directly on `Build.Builder`, refactored to expose `mergeManagedPluginList()` 
returning just the list
   
   ### Impact
   
   Each pipeline stage that modifies `Build`, `Reporting`, or 
`PluginManagement` now avoids:
   1. Materializing the immutable sub-object (no `Build.newBuilder(build)`)
   2. Building a new immutable (no `.build()`)
   3. Wrapping it back in the Model.Builder setter (no 
`builder.build(newBuild)`)
   
   On a 4383-module reactor, each module passes through ~7 pipeline stages. 
Previously, every stage that touched `Build` would: get immutable → create 
Builder → set fields → build() → set back on Model.Builder. Now they: get 
sub-builder → set fields. One allocation instead of three per stage.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to