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 — Profile-level properties from a settings.xml-activated profile are dropped before LRM init · Issue #12288 · apache/maven

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

New issue
Copy link
New issue
Copy link
Closed
#12297
Closed
Profile-level properties from a settings.xml-activated profile are dropped before LRM init#12288
#12297
Copy link

Description

@ascheman
ascheman
opened on Jun 17, 2026
Issue body actions

Background

Apache Maven Resolver lets users configure the local repository manager
through aether.* properties. The Maven user manual describes
<properties> inside a <profile> as a regular way to set them, and
the documented activation channels for such a profile are:

  • CLI: mvn -P <id>
  • settings.xml: <activeProfiles><activeProfile>...</activeProfile></activeProfiles>
  • settings.xml: <profile><activation><activeByDefault>true</activeByDefault></activation>...

The first two channels propagate the profile's <properties> to the
resolver session as expected. The third does not.

Bug

When a profile is activated through
<activation><activeByDefault>true</activeByDefault></activation> in
settings.xml, the properties declared in that profile's
<properties> block never reach the
RepositorySystemSession.configProperties that the
EnhancedLocalRepositoryManager reads at initialization. Consequently,
aether.* settings declared in an active-by-default settings.xml
profile have no effect on the LRM — but the same <properties> block
on the same <profile> works correctly when the user activates it via
-P <id> on the CLI, or via <activeProfiles><activeProfile>... in the
same settings.xml.

This is observable to the user because
mvn help:evaluate -Dexpression=aether.enhancedLocalRepository.localPrefix
does report the configured value (the property is in the Maven session
elsewhere), yet the LRM behaves as if no aether.* configuration had
been set.

Reproducer

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.example.aether</groupId>
  <artifactId>test-artifact</artifactId>
  <version>1.0</version>
  <packaging>pom</packaging>
</project>

settings.xml (active-by-default — broken case):

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0">
  <profiles>
    <profile>
      <id>aether-split-via-settings</id>
      <activation><activeByDefault>true</activeByDefault></activation>
      <properties>
        <aether.enhancedLocalRepository.split>true</aether.enhancedLocalRepository.split>
        <aether.enhancedLocalRepository.localPrefix>mvb-foo</aether.enhancedLocalRepository.localPrefix>
      </properties>
    </profile>
  </profiles>
</settings>

For comparison, the same profile activated via <activeProfiles> (works correctly):

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0">
  <activeProfiles>
    <activeProfile>aether-split-via-settings</activeProfile>
  </activeProfiles>
  <profiles>
    <profile>
      <id>aether-split-via-settings</id>
      <properties>
        <aether.enhancedLocalRepository.split>true</aether.enhancedLocalRepository.split>
        <aether.enhancedLocalRepository.localPrefix>mvb-foo</aether.enhancedLocalRepository.localPrefix>
      </properties>
    </profile>
  </profiles>
</settings>

Run with each settings file:

mvn -s settings.xml -Dmaven.repo.local=$PWD/local-repo install
find local-repo -name 'test-artifact-1.0.pom'
settings.xml activation Found at
<activeProfiles><activeProfile>... (works) local-repo/mvb-foo/org/example/aether/test-artifact/1.0/test-artifact-1.0.pom
<activeByDefault>true</activeByDefault> (broken — actual) local-repo/org/example/aether/test-artifact/1.0/test-artifact-1.0.pom
<activeByDefault>true</activeByDefault> (expected) local-repo/mvb-foo/org/example/aether/test-artifact/1.0/test-artifact-1.0.pom

Versions

  • Maven 4.x master (sha 09fdd6a6, 4.1.0-SNAPSHOT)
  • Maven 3.9.16

Likely affects all versions on both lines; backport candidate.

Activity

  1. slawekjaranowski commented on Jun 17, 2026

    @slawekjaranowski
    slawekjaranowski
    on Jun 17, 2026
    Member
    More actions

    It works as expected only <activeProfiles><activeProfile>.. can be used.

    https://maven.apache.org/guides/mini/guide-resolver-transport.html#system-level

  2. ascheman
    added 2 commits that reference this issue on Jun 17, 2026

    [apache#12288] Add ITs for settings.xml profile -> LRM

    40f7da6

    [apache#12288] Pass settings.xml profile props to LRM

    707b241
  3. ascheman commented on Jun 17, 2026

    @ascheman
    ascheman
    on Jun 17, 2026
    ContributorAuthor
    More actions

    Thanks @slawekjaranowski for the documentation pointer — I see now that the limitation was added by you in maven-site#441 / MNG-7850 (July 2023, commit 68861020). Reading the original issue and the PR discussion I cannot find an explicit why — only the observation that profile/activation is not honored at LRM init time. Is there a technical reason (timing / chicken-and-egg with the resolver session build, or otherwise) for the restriction, or is it documented because that's how it happened to behave at the time?

    The reason I ask: from a user perspective, declaring an active-by-default profile in settings.xml is the canonical Maven way to "make this always apply"; the requirement to list the profile id a second time in <activeProfiles> is non-obvious. The footgun is double-sharp because the only place this is documented is the resolver-transport mini-guide; settings.xsd and the Maven user guide don't flag the limitation.

    The fix in #12291 closes the gap for the <activeByDefault> case at the cost of seven lines in DefaultRepositorySystemSessionFactory. It deliberately does not re-implement full DefaultProfileSelector semantics (so e.g. deactivation-by-other-active-profile is not honored — PR body has the details).

    If the conclusion is to keep the existing behavior, would you accept a smaller alternative: emit a WARN when a profile has <activeByDefault>true</activeByDefault> + non-empty <properties> but its id is not in <activeProfiles> / not CLI-activated? I have a local prototype that does that in ~12 lines without behavior change; the warning text points the user directly to the two supported activation channels:

    [WARNING] Properties of profile 'aether-split-via-settings' (active-by-default) are NOT propagated
    to the resolver session config. To apply them, list the profile id under <activeProfiles> in
    settings.xml or activate via -P aether-split-via-settings on the CLI.
    

    Happy to retarget #12291 to that smaller, behavior-preserving variant if preferred. Either way, if you confirm there is a technical reason that should not be unified, I'll close the PR and follow up with a maven-site PR that makes the limitation more discoverable beyond the resolver-transport mini-guide.

  4. gnodet
    closed this as completedin #12297on Jun 17, 2026
  5. ascheman commented on Jun 17, 2026

    @ascheman
    ascheman
    on Jun 17, 2026
    ContributorAuthor
    More actions

    @gnodet @slawekjaranowski — two follow-up questions to round out the issue:

    1. Warning for the remaining activation channels?

    Earlier in this thread I had offered a warning variant as a behavior-preserving alternative for the <activeByDefault> case:

    Would you accept a smaller alternative: emit a WARN when a profile has <activeByDefault>true</activeByDefault> + non-empty <properties> but its id is not in <activeProfiles> / not CLI-activated? I have a local prototype that does that in ~12 lines without behavior change; the warning text points the user directly to the two supported activation channels […]

    Now that the fix in #12297 (and the regression-guard follow-up in #12298) handles <activeByDefault> cleanly, the warning is moot for that case. But the four other activation channels (<jdk>, <os>, <property>, <file>) still silently drop their <properties>, because their evaluation happens later in the model builder than the resolver session build.

    Would it make sense to emit a single [WARNING] from DefaultRepositorySystemSessionFactory#getPropertiesFromRequestedProfiles when a profile

    • declares one of those four activation conditions, and
    • has a non-empty <properties> block, and
    • is not active via <activeProfiles> / CLI -P

    Same shape as the earlier prototype, just scoped to non-activeByDefault activation conditions:

    [WARNING] Properties of profile '<id>' (activated via <kind>) are NOT propagated
    to the resolver session config. To apply them, list the profile id under
    <activeProfiles> in settings.xml or activate via -P <id> on the CLI.
    

    2. Backport to maven 3.9.x?

    The same bug reproduces on Maven 3.9.16 (same activation-time-vs-LRM-build-time ordering). For users who can't move to Maven 4 yet, would a backport of #12297 (and whichever shape #1 lands in) be in scope, or is the 3.9.x line strictly maintenance-only at this point?

    Happy to prepare the backport PR once you confirm direction.

    Why I'm asking together

    This affects the maven-site doc clarification I'm drafting at apache/maven-site#1602 — the final wording depends on whether the limitation gets fixed on both lines or only Maven 4, and whether there's a WARN bridging the not-yet-fixed conditions. I'll keep that doc PR as Draft until both questions are settled.

  6. ascheman commented on Jun 17, 2026

    @ascheman
    ascheman
    on Jun 17, 2026
    ContributorAuthor
    More actions

    Can we please reopen the issue and first clarify the open questions, @gnodet?

    • Should we get a back-port to M3?
    • Should we issue a warning?
    • Documentation fix is affected by these decisions.
  7. ascheman
    added 2 commits that reference this issue on Jun 17, 2026

    [apache#12288] Pass settings.xml profile properties to LRM (apache#12297

    8e86999

    [apache#12288] IT for -P !profile deactivation guard

    bbb9ab8
  8. gnodet
    reopened this on Jun 17, 2026
  9. gnodet commented on Jun 17, 2026

    @gnodet
    gnodet
    on Jun 17, 2026
    Contributor
    More actions

    This bug also reproduces on Maven 3.9.16 (as confirmed by @ascheman in #12291). The fix has been merged to master via #12297 and backported to maven-4.0.x in #12299.

    A backport to maven-3.10.x (targeting 3.10.0 / 3.9.17) should be straightforward — the same DefaultRepositorySystemSessionFactory.getPropertiesFromRequestedProfiles method exists on the 3.x branch. The activeByDefault property-propagation gap and the missing deactivation check (-P !id) apply there identically.

  10. gnodet
    added 2 commits that reference this issue on Jun 18, 2026

    [Backport 4.0.x] [#12288] Pass settings.xml profile properties to LRM (…

    50c1b17

    Fix NIO2 compilation errors in test files merged from master

    429acd3
  11. slawekjaranowski commented on Jun 18, 2026

    @slawekjaranowski
    slawekjaranowski
    on Jun 18, 2026
    Member
    More actions

    By the way I see that activeByDefault in settings.xml has different behavior than in pom.xml.

    In settings.xml such profiles are always activated regardless of profile defined in activeProfiles and profile provided by -P options

    In pom.xml profiles are only activated if no other profiles are activated.

    It should be documented somewher.

  12. slawekjaranowski commented on Jun 18, 2026

    @slawekjaranowski
    slawekjaranowski
    on Jun 18, 2026
    Member
    More actions

    Would it make sense to emit a single [WARNING] from DefaultRepositorySystemSessionFactory#getPropertiesFromRequestedProfiles when a profile

    • declares one of those four activation conditions, and
    • has a non-empty <properties> block, and
    • is not active via <activeProfiles> / CLI -P

    I would like to not emit such warnings, we don't known which properties are for repositories session.

  13. slawekjaranowski commented on Jun 18, 2026

    @slawekjaranowski
    slawekjaranowski
    on Jun 18, 2026
    Member
    More actions

    Backport to maven 3.9.x - I'm not sure - but can be
    for 3.10.x I'm for do it.

    Reacted by Gerd Aschemann
  14. gnodet
    added 2 commits that reference this issue on Jun 18, 2026

    [#12288] Add -P !profile deactivation regression guard (#12298)

    22f9a0e

    [Backport 4.0.x] [#12288] Add -P !profile deactivation regression gua…

    6e190d4
  15. ascheman commented on Jun 19, 2026

    @ascheman
    ascheman
    on Jun 19, 2026
    ContributorAuthor
    More actions

    Backport to maven 3.9.x - I'm not sure - but can be for 3.10.x I'm for do it.

    Yes, 3.10, I am about to prepare it, stay tuned.

  16. ascheman commented on Jun 19, 2026

    @ascheman
    ascheman
    on Jun 19, 2026
    ContributorAuthor
    More actions

    Would it make sense to emit a single [WARNING] from DefaultRepositorySystemSessionFactory#getPropertiesFromRequestedProfiles when a profile

    • declares one of those four activation conditions, and
    • has a non-empty <properties> block, and
    • is not active via <activeProfiles> / CLI -P

    I would like to not emit such warnings, we don't known which properties are for repositories session.

    It's not about these particular properties but for any property which is ignored by the profile filtering. The user should be informed that their configuration is not used IMHO.

  17. ascheman
    added a commit that references this issue on Jun 22, 2026

    [#12288] Pass settings.xml activeByDefault profile props to LRM

    74f3adb
  18. gnodet commented on Jun 23, 2026

    @gnodet
    gnodet
    on Jun 23, 2026
    Contributor
    More actions

    Fixed by:

    • PR [#12288] Pass settings.xml profile properties to LRM #12297 (master)
    • PR [Backport 4.0.x] [#12288] Pass settings.xml profile properties to LRM #12299 (backport to maven-4.0.x)
    • PR [Backport 4.0.x] [#12288] Add -P !profile deactivation regression guard (#12298) #12315 (backport to maven-4.0.x — profile deactivation regression guard)
    • PR [#12288] Backport: settings.xml activeByDefault profile props to LRM #12333 (backport to maven-3.10.x)
  19. gnodet
    closed this as completedon Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.