This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch gh-12288-lrm-profile-properties in repository https://gitbox.apache.org/repos/asf/maven.git
commit 704203ac5f3713d5b71528e4d7b0f0ca4975b09d Author: Guillaume Nodet <[email protected]> AuthorDate: Wed Jun 17 15:31:29 2026 +0200 [#12288] Remove redundant getActiveProfiles() call and respect profile deactivation - request.getActiveProfiles() returns the same set already collected via getRequiredActiveProfileIds() + getOptionalActiveProfileIds(), so it was a no-op. Remove it. - The activeByDefault filter must exclude profiles explicitly deactivated via -P !id, otherwise deactivation is silently ignored. Co-Authored-By: Claude Opus 4.6 <[email protected]> --- .../aether/DefaultRepositorySystemSessionFactory.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/impl/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java b/impl/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java index 57a5210e19..aff1423b9c 100644 --- a/impl/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java +++ b/impl/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java @@ -433,14 +433,16 @@ private Map<String, String> getPropertiesFromRequestedProfiles(MavenExecutionReq HashSet<String> activeProfileId = new HashSet<>(request.getProfileActivation().getRequiredActiveProfileIds()); activeProfileId.addAll(request.getProfileActivation().getOptionalActiveProfileIds()); - // 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()); return request.getProfiles().stream() .filter(profile -> activeProfileId.contains(profile.getId()) - || (profile.getActivation() != null + || (!inactiveProfileId.contains(profile.getId()) + && profile.getActivation() != null && profile.getActivation().isActiveByDefault())) .map(ModelBase::getProperties) .flatMap(properties -> properties.entrySet().stream())
