GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [#12288] Pass settings.xml profile properties to LRM by ascheman · Pull Request #12291 · apache/maven

Conversation

@ascheman

@ascheman ascheman commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #12288.

Profiles activated through settings.xml (<activeProfiles> or
<activation><activeByDefault>true</activeByDefault>) had their
<properties> block dropped before the resolver session was built, so
aether.* configuration declared in such a profile silently failed.
The same <properties> on the same <profile> worked when activated
via CLI -P.

Changes

  1. Two ITs in core-it-suite covering both settings.xml activation
    channels — testActiveByDefaultProfile (red on master) and
    testActiveProfilesList (green on master, regression guard).
  2. DefaultRepositorySystemSessionFactory#getPropertiesFromRequestedProfiles
    extended to also consider request.getActiveProfiles() and
    <activeByDefault>true</activeByDefault> profiles.

Locally verified against the core-it-suite:

  • master + new ITs: 1 of 2 fail (testActiveByDefaultProfile)
  • master + new ITs + fix: 2 of 2 pass

Scope

Only the profile's <properties> block is affected — other profile
content (<plugins>, <dependencies>, <repositories>, …) flows
through its existing channels unchanged.

Limitation: this does not re-implement the full DefaultProfileSelector
semantics (e.g. activeByDefault deactivation when other profiles of
the same source are active). For the property-propagation use case in
scope of #12288 this is sufficient; injecting ProfileSelector here
would be a larger refactor in a session-build hot path and is left to a
follow-up if needed.

Affected versions

Reproduces on Maven 4.x master and on Maven 3.9.16; backport candidate.

Test plan

  • mvn install on apache-maven from the branch builds cleanly
  • mvn verify -Prun-its -DmavenDistro=… -Dit.test=MavenITSettingsProfileAetherPropertiesTest on the patched dist: both ITs green
  • Same command on vanilla master dist: testActiveByDefaultProfile red, testActiveProfilesList green
  • core-it-suite full run (not done locally — CI takes it from here)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ascheman added 2 commits June 17, 2026 12:28
@ascheman
[apache#12288] Add ITs for settings.xml profile -> LRM
40f7da6
Adds two integration tests asserting that <properties> declared in
a settings.xml <profile> reach the resolver session config before
the LocalRepositoryManager is initialized.

The fixtures use aether.enhancedLocalRepository.{split,localPrefix}
because those have an observable effect on the install path, but the
propagation gap covered by the tests applies to any profile property.
Only the profile's <properties> block is consumed; the profile's
<plugins>, <dependencies>, <repositories>, etc. are not in scope here.

Both settings.xml-only activation channels are covered:
* testActiveByDefaultProfile -- <activation><activeByDefault>true</...
* testActiveProfilesList     -- <activeProfiles><activeProfile>...

On unmodified master, testActiveByDefaultProfile is RED (the bug) and
testActiveProfilesList is GREEN (acts as a regression guard for the
channel that already propagates correctly).
@ascheman
[apache#12288] Pass settings.xml profile props to LRM
707b241
DefaultRepositorySystemSessionFactory#getPropertiesFromRequestedProfiles
previously only considered CLI-activated profile ids (-P). Profiles
activated through settings.xml (<activeProfiles> or <activeByDefault>)
were filtered out, so any <properties> they declared were dropped
before the resolver session was built. aether.* configuration was the
most visible casualty (LRM split/localPrefix etc.), but the gap
affects every property declared in such a profile.

The fix only touches profile <properties>; other profile content
(<plugins>, <dependencies>, <repositories>, ...) is unchanged and
keeps flowing through its existing project/build channels.

Extend the active-profile-id set with request.getActiveProfiles() and
add an isActiveByDefault() branch to the filter.

Note: this does not re-implement the full DefaultProfileSelector
semantics (e.g. activeByDefault deactivation when other profiles of
the same source are active). For the property-propagation use case in
scope of apache#12288 this is sufficient; injecting ProfileSelector here
would be a larger refactor in a session-build hot path and is left to
a follow-up if needed.
@ascheman ascheman mentioned this pull request Jun 17, 2026
Profile-level properties from a settings.xml-activated profile are dropped before LRM init #12288
Closed
gnodet
gnodet requested changes Jun 17, 2026
View reviewed changes

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this well-documented PR, @ascheman — the bug report and reproducer are thorough, and the fix targets the right method.

Two issues to address, one correctness gap and one redundancy:

  1. Missing deactivation check: The activeByDefault branch doesn't exclude profiles explicitly deactivated via -P !profileId. A user running mvn -P !aether-split-via-settings would expect the profile to be deactivated, but the current code still includes its properties.

  2. Redundant request.getActiveProfiles() call: request.getActiveProfiles() returns the exact union of getRequiredActiveProfileIds() + getOptionalActiveProfileIds() (already collected above). The settings.xml <activeProfiles> list flows via overwriteActiveProfiles() → activateOptionalProfile(), so they're already in getOptionalActiveProfileIds(). The real fix is the activeByDefault check — the getActiveProfiles() line adds nothing.

See inline suggestions for concrete fixes.

Note: this review does not replace specialized AI review tools (CodeRabbit, Sourcery) or static analysis (SonarCloud).

Fully automatic review from Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...re/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
Comment on lines +436 to +439
// Also include profiles activated via settings.xml <activeProfiles> so that their
// properties (notably aether.* configuration) reach the resolver session config in
// time for LocalRepositoryManager initialization.
activeProfileId.addAll(request.getActiveProfiles());

@gnodet gnodet Jun 17, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request.getActiveProfiles() delegates to profileActivation.getActiveProfiles(), which returns all IDs where active() == true — the exact union of getRequiredActiveProfileIds() + getOptionalActiveProfileIds() already collected above. The settings.xml <activeProfiles> list is wired via overwriteActiveProfiles() → activateOptionalProfile(), so those IDs are already in getOptionalActiveProfileIds().

This block should instead collect inactive profile IDs, so the activeByDefault filter below can respect explicit deactivation (-P !profileId):

Suggested change
// Also include profiles activated via settings.xml <activeProfiles> so that their
// properties (notably aether.* configuration) reach the resolver session config in
// time for LocalRepositoryManager initialization.
activeProfileId.addAll(request.getActiveProfiles());
// Profiles explicitly deactivated via -P !id must be excluded even if they
// declare activeByDefault=true.
HashSet<String> inactiveProfileId =
new HashSet<>(request.getProfileActivation().getRequiredInactiveProfileIds());
inactiveProfileId.addAll(request.getProfileActivation().getOptionalInactiveProfileIds());

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...re/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
Comment on lines +442 to +444
.filter(profile -> activeProfileId.contains(profile.getId())
|| (profile.getActivation() != null
&& profile.getActivation().isActiveByDefault()))

@gnodet gnodet Jun 17, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The activeByDefault branch should exclude profiles that have been explicitly deactivated:

Suggested change
.filter(profile -> activeProfileId.contains(profile.getId())
|| (profile.getActivation() != null
&& profile.getActivation().isActiveByDefault()))
.filter(profile -> activeProfileId.contains(profile.getId())
|| (!inactiveProfileId.contains(profile.getId())
&& profile.getActivation() != null
&& profile.getActivation().isActiveByDefault()))

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...e-it-suite/src/test/java/org/apache/maven/it/MavenITSettingsProfileAetherPropertiesTest.java
* settings.xml activation channels fail, which is what these tests guard
* against.
*/
public class MavenITSettingsProfileAetherPropertiesTest extends AbstractMavenIntegrationTestCase {

@gnodet gnodet Jun 17, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: other ITs fixing tracked issues typically follow the MavenITgh<number>...Test pattern (e.g. MavenITgh10210SettingsXmlDecryptTest). Consider renaming to MavenITgh12288SettingsProfileAetherPropertiesTest for consistency and traceability.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gnodet gnodet mentioned this pull request Jun 17, 2026
[#12288] Pass settings.xml profile properties to LRM #12297
Merged
@ascheman

ascheman commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #12297 — closing in favor of @gnodet's reroll. Thanks for picking it up and preserving attribution.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ascheman ascheman closed this Jun 17, 2026
@ascheman ascheman mentioned this pull request Jun 17, 2026
[#12288] Add -P !profile deactivation regression guard #12298
Merged
gnodet added a commit that referenced this pull request Jun 17, 2026
@gnodet @ascheman
[#12288] Pass settings.xml profile properties to LRM (#12297)
8e86999
Fixes #12288. Supersedes #12291.

Profiles activated through settings.xml (<activeProfiles> or
<activation><activeByDefault>true</activeByDefault>) had their
<properties> block dropped before the resolver session was built, so
aether.* configuration declared in such a profile silently failed.

Changes:
- Collect activeByDefault profiles for property propagation to LRM
- Respect -P !profileId deactivation for activeByDefault profiles
- Add ITs for both settings.xml activation channels

Co-authored-by: Gerd Aschemann <[email protected]>
gnodet added a commit that referenced this pull request Jun 18, 2026
@gnodet @ascheman
[Backport 4.0.x] [#12288] Pass settings.xml profile properties to LRM (…
50c1b17
…#12299)

Fixes #12288. Supersedes #12291.

Profiles activated through settings.xml (<activeProfiles> or
<activation><activeByDefault>true</activeByDefault>) had their
<properties> block dropped before the resolver session was built, so
aether.* configuration declared in such a profile silently failed.

Changes:
- Collect activeByDefault profiles for property propagation to LRM
- Respect -P !profileId deactivation for activeByDefault profiles
- Add ITs for both settings.xml activation channels

Co-authored-by: Gerd Aschemann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gnodet gnodet gnodet requested changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Profile-level properties from a settings.xml-activated profile are dropped before LRM init

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@ascheman @gnodet
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.