This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch maven-4.0.x
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/maven-4.0.x by this push:
new 6e190d495e [Backport 4.0.x] [#12288] Add -P !profile deactivation
regression guard (#12298)
6e190d495e is described below
commit 6e190d495ec5e0b3aae8ffd3c9d4375c9e8ca607
Author: Guillaume Nodet <[email protected]>
AuthorDate: Thu Jun 18 19:32:10 2026 +0200
[Backport 4.0.x] [#12288] Add -P !profile deactivation regression guard
(#12298)
* [#12288] IT for -P !profile deactivation guard
Adds a third IT alongside testActiveByDefaultProfile and
testActiveProfilesList:
* testActiveByDefaultDeactivatedViaCli -- guards that -P !profileId
still deactivates an <activeByDefault> profile, so its <properties>
are NOT merged into the resolver session config.
This explicitly covers the deactivation path added in the previous
commit and prevents future regressions in the activeByDefault filter
logic.
A small deleteRecursivelyIfExists helper prevents false positives if
sibling tests (which install under the same custom prefix) ran first.
* Update
its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh12288SettingsProfileAetherPropertiesTest.java
* Apply suggestions from code review
* Update
its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh12288SettingsProfileAetherPropertiesTest.java
---------
Co-authored-by: Gerd Aschemann <[email protected]>
---
...gh12288SettingsProfileAetherPropertiesTest.java | 37 ++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git
a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh12288SettingsProfileAetherPropertiesTest.java
b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh12288SettingsProfileAetherPropertiesTest.java
index d3abfa3032..b6134ffe7b 100644
---
a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh12288SettingsProfileAetherPropertiesTest.java
+++
b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh12288SettingsProfileAetherPropertiesTest.java
@@ -20,6 +20,7 @@
import java.io.File;
+import org.codehaus.plexus.util.FileUtils;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -69,6 +70,42 @@ public void testActiveProfilesList() throws Exception {
runAndAssertCustomPrefix("settings-active-profiles-list.xml");
}
+ @Test
+ public void testActiveByDefaultDeactivatedViaCli() throws Exception {
+ File testDir = extractResources("/settings-profile-aether-properties");
+
+ Verifier verifier = newVerifier(testDir.getAbsolutePath());
+ verifier.setAutoclean(false);
+ verifier.setLogFileName("log-deactivation.txt");
+ verifier.deleteDirectory("target");
+
verifier.deleteArtifacts("org.apache.maven.its.settings.profile.aether");
+
+ // Sibling tests in this class install under the same custom prefix;
clear it to
+ // avoid false positives if those tests ran first.
+ File customPrefixSubtree = new File(verifier.getLocalRepository(),
"it-custom-prefix");
+ FileUtils.deleteDirectory(customPrefixSubtree);
+
+ verifier.addCliArgument("--settings");
+ verifier.addCliArgument("settings-active-by-default.xml");
+ verifier.addCliArgument("-P!aether-split-via-settings");
+ verifier.addCliArgument("install");
+ verifier.execute();
+ verifier.verifyErrorFreeLog();
+
+ File localRepo = new File(verifier.getLocalRepository());
+ String gavRelativePath =
"org/apache/maven/its/settings/profile/aether/test-artifact/1.0/test-artifact-1.0.pom";
+ File flatLayout = new File(localRepo, gavRelativePath);
+ File customPrefix = new File(localRepo, "it-custom-prefix/" +
gavRelativePath);
+
+ assertTrue(
+ flatLayout.exists(),
+ "Expected artifact at flat layout (profile deactivated via -P
!), but not found at " + flatLayout);
+
+ assertFalse(
+ customPrefix.exists(),
+ "Found artifact at custom prefix " + customPrefix + " —
deactivation via -P ! was ignored.");
+ }
+
private void runAndAssertCustomPrefix(String settingsFile) throws
Exception {
File testDir = extractResources("/settings-profile-aether-properties");