mvanhorn opened a new pull request, #12419:
URL: https://github.com/apache/maven/pull/12419
## Summary
Projects with duplicate profile ids build again instead of dying with
`java.lang.IllegalStateException: Duplicate key default (attempted merging
values ...)`. Maven 3 accepted these POMs; Maven 4 rc-1/rc-2 crash during
dependency collection.
## Why this matters
In #10209, @gnodet confirmed the exception is misleading: the activation
save/restore map in model building is keyed by profile id, so the real
condition is two `<profile>` entries sharing an id (e.g. two
`<id>default</id>`), surfacing as an opaque JDK collector error instead of a
model diagnostic. @cstamas linked the regression to the MNG-8391 change. The
issue is labeled bug/priority:major with no prior PRs.
## Changes
- `getProfileActivations` / `injectProfileActivations` in
`DefaultModelBuilder` no longer key the activation save/restore by profile id -
activations round-trip positionally with `model.getProfiles()`, so duplicate
ids cannot collide in a map. This restores Maven 3's leniency in the
model-building path while `DefaultModelValidator` remains the single owner of
the duplicate-id diagnostic ("must be unique but found duplicate profile with
id ..."), so no raw `IllegalStateException` escapes to the user.
## Testing
`mvn -pl impl/maven-impl -am test -Dtest=DefaultModelBuilderTest` - 13
tests, 0 failures, including a new test with `duplicate-profile-ids.xml` (two
profiles sharing an id, each with its own activation) verifying model building
succeeds and both activations survive the save/restore round-trip.
Fixes #10209
--
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]