[#12288] Backport: settings.xml activeByDefault profile props to LRM#12333
Conversation
Backport of the master fix (apache#12297) and gnodet's review hardening to the maven-3.10.x line. On 3.x, request.getActiveProfiles() already covers both CLI -P and settings.xml <activeProfiles>, so only the <activeByDefault> channel was broken. The activeByDefault filter is guarded against -P !id deactivation per gnodet's review feedback. Cherry-picks could not be applied verbatim due to path and API divergence: * Path: 3.x has maven-core/src/main/java/..., master has impl/maven-core/src/main/java/... * API: 3.x exposes request.getActiveProfiles() / getInactiveProfiles() returning List<String>; master uses request.getProfileActivation().get{Required,Optional}{Active,Inactive} ProfileIds(). The minimal-diff adaptation here only adds the activeByDefault branch and -P !id guard; the existing settings.xml <activeProfiles> propagation is unchanged. Master origin commits: * 3e2c756 ([apache#12288] fix) * 5785235 (gnodet review hardening) Integration tests live in apache/maven-integration-testing and are addressed in a separate PR. Co-Authored-By: Guillaume Nodet <gnodet@gmail.com>
gnodet
left a comment
There was a problem hiding this comment.
Clean, minimal, well-documented backport. CI is fully green (18/18).
Correctness
The filter predicate is structurally identical to the master fix (#12297):
activeIds.contains(id) || (!inactiveIds.contains(id) && activation != null && isActiveByDefault())
The API adaptation from ProfileActivation.getRequired/OptionalActive/InactiveProfileIds() (master) to request.getActiveProfiles()/getInactiveProfiles() (3.x) is correct — on 3.x, getActiveProfiles() already returns the union of CLI -P and settings.xml <activeProfiles> (confirmed in DefaultMavenExecutionRequestPopulator), so the separate channel propagation from master is not needed.
Null safety (profile.getActivation() != null), deactivation guard (!inactiveProfileId.contains(...)), and property override safety (this method's output is overridden by system/user properties downstream) all check out.
Minor observations (non-blocking)
-
The master fix added
.filter(e -> e.getValue() != null)beforecollect(). This backport omits it, but this is consistent with pre-existing 3.x code, andProperties(fromModelBase.getProperties()) cannot contain null values byHashtablecontract — harmless. -
Worth linking the companion
apache/maven-integration-testingPR here once it's open, for traceability.
Fully automatic review from Claude Code. This review does not replace specialized AI review tools or static analysis.
@gnodet — for review (you endorsed this backport in #12288).
Backport of #12297 (merged on master, also backported to
maven-4.0.xvia #12299) to the
maven-3.10.xmaintenance line:What changes (on 3.x)
Adapted minimal-diff (4 net lines added to
DefaultRepositorySystemSessionFactory#getPropertiesFromRequestedProfiles):<activation><activeByDefault>true</activeByDefault>branch tothe profile filter — this is the actual gap on 3.x.
-P !iddeactivation guard (per the review hardening onmaster,
57852351).On 3.x,
request.getActiveProfiles()already returns CLI-P+ settings.xml<activeProfiles>, so the master fix's additional propagation of thosechannels is not needed on this line. Only
<activeByDefault>wasbroken on 3.10.x.
Why not a verbatim cherry-pick
Path and API divergence between master and 3.10.x prevented a clean
cherry-pick -x:impl/maven-core/src/main/java/...; 3.x hasmaven-core/src/main/java/....request.getProfileActivation().get{Required,Optional}{Active,Inactive}ProfileIds();3.x uses
request.getActiveProfiles()/getInactiveProfiles()returningList<String>.The commit body explicitly cites the master origin commits
(
3e2c7560and57852351) for traceability.Tests
Integration tests for #12288 on the 3.x line live in
apache/maven-integration-testingand are addressed by a parallel PR there (will reference here once open).
The IT coverage includes:
testActiveByDefaultProfile(master7725eaf2)testActiveProfilesList(master7725eaf2, baseline regression guard)testActiveByDefaultDeactivatedViaCli(master [#12288] Add -P !profile deactivation regression guard #12298, regression guard forthe
-P !iddeactivation that is also in this PR)Locally:
mvn -pl maven-core -am clean install— green.References #12288, #12297, #12298, #12299.