This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch cherry-pick-12298-to-4.0.x in repository https://gitbox.apache.org/repos/asf/maven.git
commit 44f22c661667afc602380704f9b38abec3170f4a Author: Gerd Aschemann <[email protected]> AuthorDate: Thu Jun 18 19:30:44 2026 +0200 [#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 Co-authored-by: Guillaume Nodet <[email protected]> * Update its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh12288SettingsProfileAetherPropertiesTest.java --------- Co-authored-by: Guillaume Nodet <[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");
