gnodet commented on code in PR #12291:
URL: https://github.com/apache/maven/pull/12291#discussion_r3428524881
##########
impl/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java:
##########
@@ -433,9 +433,15 @@ 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());
return request.getProfiles().stream()
- .filter(profile -> activeProfileId.contains(profile.getId()))
+ .filter(profile -> activeProfileId.contains(profile.getId())
+ || (profile.getActivation() != null
+ &&
profile.getActivation().isActiveByDefault()))
Review Comment:
The `activeByDefault` branch should exclude profiles that have been
explicitly deactivated:
```suggestion
.filter(profile -> activeProfileId.contains(profile.getId())
|| (!inactiveProfileId.contains(profile.getId())
&& profile.getActivation() != null
&&
profile.getActivation().isActiveByDefault()))
```
##########
impl/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java:
##########
@@ -433,9 +433,15 @@ 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());
Review Comment:
`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`):
```suggestion
// 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());
```
##########
its/core-it-suite/src/test/java/org/apache/maven/it/MavenITSettingsProfileAetherPropertiesTest.java:
##########
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.it;
+
+import java.io.File;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Integration tests proving that {@code aether.*} properties declared in the
+ * {@code <properties>} block of a {@code settings.xml} profile are honored
+ * by the resolver at local repository manager initialization, regardless of
+ * which settings.xml-only activation channel was used.
+ *
+ * <p>Two activation channels are covered:
+ * <ul>
+ * <li>{@code
<activation><activeByDefault>true</activeByDefault></activation>}
+ * on the profile itself;</li>
+ * <li>{@code
<activeProfiles><activeProfile>...</activeProfile></activeProfiles>}
+ * at the top of {@code settings.xml}.</li>
+ * </ul>
+ *
+ * <p>In both cases the same profile sets:
+ * <pre>
+ * aether.enhancedLocalRepository.split = true
+ * aether.enhancedLocalRepository.localPrefix = it-custom-prefix
+ * </pre>
+ * and the test asserts that {@code mvn install} writes the installed pom
+ * under {@code <localRepo>/it-custom-prefix/<groupId-path>/...} rather
+ * than the flat or default-split layout.
+ *
+ * <p>The same properties on the same profile work correctly when the
+ * profile is activated via {@code -P <id>} on the CLI; only the
+ * settings.xml activation channels fail, which is what these tests guard
+ * against.
+ */
+public class MavenITSettingsProfileAetherPropertiesTest extends
AbstractMavenIntegrationTestCase {
Review Comment:
Nit: other ITs fixing tracked issues typically follow the
`MavenITgh<number>...Test` pattern (e.g.
`MavenITgh10210SettingsXmlDecryptTest`). Consider renaming to
`MavenITgh12288SettingsProfileAetherPropertiesTest` for consistency and
traceability.
--
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]