From 216c16c4b34f56aebbb64c702f0325fdf43a4b10 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Fri, 25 Oct 2024 17:33:53 +0200 Subject: [PATCH] [MNG-8360] IT for subproject profile activation (#396) --- ...ng8360SubprojectProfileActivationTest.java | 55 +++++++++++++++++++ .../apache/maven/it/TestSuiteOrdering.java | 1 + .../test/resources/mng-8360/.mvn/maven.config | 2 + .../test/resources/mng-8360/module1/pom.xml | 6 ++ .../src/test/resources/mng-8360/pom.xml | 35 ++++++++++++ .../src/test/resources/mng-8360/settings.xml | 13 +++++ 6 files changed, 112 insertions(+) create mode 100644 its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8360SubprojectProfileActivationTest.java create mode 100644 its/core-it-suite/src/test/resources/mng-8360/.mvn/maven.config create mode 100644 its/core-it-suite/src/test/resources/mng-8360/module1/pom.xml create mode 100644 its/core-it-suite/src/test/resources/mng-8360/pom.xml create mode 100644 its/core-it-suite/src/test/resources/mng-8360/settings.xml diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8360SubprojectProfileActivationTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8360SubprojectProfileActivationTest.java new file mode 100644 index 0000000000..e7c77f7a7a --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8360SubprojectProfileActivationTest.java @@ -0,0 +1,55 @@ +/* + * 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.apache.maven.shared.verifier.Verifier; +import org.apache.maven.shared.verifier.util.ResourceExtractor; +import org.junit.jupiter.api.Test; + +/** + * This is a test set for MNG-8341. + */ +class MavenITmng8360SubprojectProfileActivationTest extends AbstractMavenIntegrationTestCase { + + MavenITmng8360SubprojectProfileActivationTest() { + super("[4.0.0-beta-6,)"); + } + + /** + * Verify that the build succeeds + */ + @Test + void testDeadlock() throws Exception { + File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8360"); + + Verifier verifier = newVerifier(testDir.getAbsolutePath()); + verifier.addCliArguments("-s", "settings.xml"); + verifier.addCliArguments("-f", "module1"); + verifier.addCliArgument("org.apache.maven.plugins:maven-help-plugin:3.3.0:active-profiles"); + verifier.execute(); + verifier.verifyErrorFreeLog(); + + // verify the three profiles have been activated + verifier.verifyTextInLog("settings-xml-activeProfiles"); + verifier.verifyTextInLog("profile_active_from_mvn_config"); + verifier.verifyTextInLog("profile_active_from_condition"); + } +} diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java b/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java index 2109042e5f..e864606d7b 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java @@ -120,6 +120,7 @@ public class TestSuiteOrdering implements ClassOrderer { * the tests are to finishing. Newer tests are also more likely to fail, so this is * a fail fast technique as well. */ + suite.addTestSuite(MavenITmng8360SubprojectProfileActivationTest.class); suite.addTestSuite(MavenITmng8347TransitiveDependencyManagerTest.class); suite.addTestSuite(MavenITmng8341DeadlockTest.class); suite.addTestSuite(MavenITmng8331VersionedAndUnversionedDependenciesTest.class); diff --git a/its/core-it-suite/src/test/resources/mng-8360/.mvn/maven.config b/its/core-it-suite/src/test/resources/mng-8360/.mvn/maven.config new file mode 100644 index 0000000000..6b7fcccb4c --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-8360/.mvn/maven.config @@ -0,0 +1,2 @@ +-P profile_active_from_mvn_config +-Dprofile_active_from_condition=true diff --git a/its/core-it-suite/src/test/resources/mng-8360/module1/pom.xml b/its/core-it-suite/src/test/resources/mng-8360/module1/pom.xml new file mode 100644 index 0000000000..62ab3c3c22 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-8360/module1/pom.xml @@ -0,0 +1,6 @@ + + + + module1 + pom + diff --git a/its/core-it-suite/src/test/resources/mng-8360/pom.xml b/its/core-it-suite/src/test/resources/mng-8360/pom.xml new file mode 100644 index 0000000000..29b733291d --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-8360/pom.xml @@ -0,0 +1,35 @@ + + + com.github.mattnelson + profiles + 1.0.0-SNAPSHOT + pom + + + profile_active_by_default + + true + + + parent + + + + profile_active_from_mvn_config + + parent + + + + profile_active_from_condition + + + profile_active_from_condition + + + + parent + + + + diff --git a/its/core-it-suite/src/test/resources/mng-8360/settings.xml b/its/core-it-suite/src/test/resources/mng-8360/settings.xml new file mode 100644 index 0000000000..c5e1382443 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-8360/settings.xml @@ -0,0 +1,13 @@ + + + false + + settings-xml-activeProfiles + + + + settings-xml-activeProfiles + + +