[MNG-8360] IT for subproject profile activation (#396)

This commit is contained in:
Guillaume Nodet 2024-10-25 17:33:53 +02:00 committed by GitHub
parent 8dc7f3b990
commit 216c16c4b3
6 changed files with 112 additions and 0 deletions

View File

@ -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 <a href="https://issues.apache.org/jira/browse/MNG-8341">MNG-8341</a>.
*/
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");
}
}

View File

@ -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 * the tests are to finishing. Newer tests are also more likely to fail, so this is
* a fail fast technique as well. * a fail fast technique as well.
*/ */
suite.addTestSuite(MavenITmng8360SubprojectProfileActivationTest.class);
suite.addTestSuite(MavenITmng8347TransitiveDependencyManagerTest.class); suite.addTestSuite(MavenITmng8347TransitiveDependencyManagerTest.class);
suite.addTestSuite(MavenITmng8341DeadlockTest.class); suite.addTestSuite(MavenITmng8341DeadlockTest.class);
suite.addTestSuite(MavenITmng8331VersionedAndUnversionedDependenciesTest.class); suite.addTestSuite(MavenITmng8331VersionedAndUnversionedDependenciesTest.class);

View File

@ -0,0 +1,2 @@
-P profile_active_from_mvn_config
-Dprofile_active_from_condition=true

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.1.0">
<parent />
<artifactId>module1</artifactId>
<packaging>pom</packaging>
</project>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.1.0" root="true">
<groupId>com.github.mattnelson</groupId>
<artifactId>profiles</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<profiles>
<profile>
<id>profile_active_by_default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<profile_active_by_default>parent</profile_active_by_default>
</properties>
</profile>
<profile>
<id>profile_active_from_mvn_config</id>
<properties>
<profile_active_from_mvn_config>parent</profile_active_from_mvn_config>
</properties>
</profile>
<profile>
<id>profile_active_from_condition</id>
<activation>
<property>
<name>profile_active_from_condition</name>
</property>
</activation>
<properties>
<profile_active_from_condition>parent</profile_active_from_condition>
</properties>
</profile>
</profiles>
</project>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<interactiveMode>false</interactiveMode>
<activeProfiles>
<activeProfile>settings-xml-activeProfiles</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>settings-xml-activeProfiles</id>
</profile>
</profiles>
</settings>