You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kw...@apache.org on 2022/10/19 06:11:50 UTC

[maven-integration-testing] 01/01: [MNG-6609] packaging specific profile activation

This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch feature/packaging-based-profile
in repository https://gitbox.apache.org/repos/asf/maven-integration-testing.git

commit c99801d1587b511a359f63f01776e066dfece9b7
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Wed Oct 19 08:11:43 2022 +0200

    [MNG-6609] packaging specific profile activation
---
 ...ITmng6609ProfileActivationForPackagingTest.java |  49 ++++++++++
 .../org/apache/maven/it/TestSuiteOrdering.java     |   1 +
 .../resources/mng-6609/jar-no-packaging/pom.xml    |  35 +++++++
 .../src/test/resources/mng-6609/jar/pom.xml        |  36 +++++++
 core-it-suite/src/test/resources/mng-6609/pom.xml  | 103 +++++++++++++++++++++
 .../src/test/resources/mng-6609/war/pom.xml        |  36 +++++++
 6 files changed, 260 insertions(+)

diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6609ProfileActivationForPackagingTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6609ProfileActivationForPackagingTest.java
new file mode 100644
index 000000000..81692033e
--- /dev/null
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6609ProfileActivationForPackagingTest.java
@@ -0,0 +1,49 @@
+package org.apache.maven.it;
+
+import java.io.File;
+import java.util.Properties;
+
+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-6609">MNG-6609</a>.
+ * Similar to {@link MavenITmng2276ProfileActivationBySettingsPropertyTest}.
+ */
+class MavenITmng6609ProfileActivationForPackagingTest
+    extends AbstractMavenIntegrationTestCase
+{
+
+    public MavenITmng6609ProfileActivationForPackagingTest()
+    {
+        super( "[4.0.0-alpha-3,)" );
+    }
+
+    /**
+     * Verify that builds uses packaging based activation.
+     * Each profile writes a Maven property named "packaging" with a different value (containing the actual packaging)
+     *
+     * @throws Exception in case of failure
+     */
+    @Test
+    void testitMojoExecution()
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6609" );
+
+        Verifier verifier = newVerifier( testDir.getAbsolutePath() );
+        verifier.setAutoclean( false );
+        verifier.deleteDirectory( "target" );
+        verifier.executeGoal( "validate" );
+        verifier.verifyErrorFreeLog();
+        Properties props = verifier.loadProperties( "target/profile.properties" );
+        assertEquals( "pom", props.getProperty( "project.properties.packaging" ) );
+        props = verifier.loadProperties( "jar/target/profile.properties" );
+        assertEquals( "jar", props.getProperty( "project.properties.packaging" ) );
+        props = verifier.loadProperties( "jar-no-packaging/target/profile.properties" );
+        assertEquals( "jar", props.getProperty( "project.properties.packaging" ) );
+        props = verifier.loadProperties( "war/target/profile.properties" );
+        assertEquals( "war", props.getProperty( "project.properties.packaging" ) );
+    }
+}
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java b/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
index 18e35dfa5..d5bb4f0e5 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
@@ -105,6 +105,7 @@ public class TestSuiteOrdering implements ClassOrderer
          * a fail fast technique as well.
          */
 
+        suite.addTestSuite( MavenITmng6609ProfileActivationForPackagingTest.class );
         suite.addTestSuite( MavenITmng5889FindBasedir.class );
         suite.addTestSuite( MavenITmng7360BuildConsumer.class );
         suite.addTestSuite( MavenITmng5452MavenBuildTimestampUTCTest.class );
diff --git a/core-it-suite/src/test/resources/mng-6609/jar-no-packaging/pom.xml b/core-it-suite/src/test/resources/mng-6609/jar-no-packaging/pom.xml
new file mode 100644
index 000000000..1563cacf6
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6609/jar-no-packaging/pom.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>jar-no-packaging</artifactId>
+  <version>0.1</version>
+
+  <name>Maven Integration Test :: MNG-6609 :: Jar (no packaging)</name>
+
+  <parent>
+    <groupId>org.apache.maven.its.mng6609</groupId>
+    <artifactId>test</artifactId>
+    <version>0.1</version>
+  </parent>
+</project>
\ No newline at end of file
diff --git a/core-it-suite/src/test/resources/mng-6609/jar/pom.xml b/core-it-suite/src/test/resources/mng-6609/jar/pom.xml
new file mode 100644
index 000000000..4771eed50
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6609/jar/pom.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>jar</artifactId>
+  <version>0.1</version>
+  <packaging>jar</packaging>
+
+  <name>Maven Integration Test :: MNG-6609 :: Jar</name>
+
+  <parent>
+    <groupId>org.apache.maven.its.mng6609</groupId>
+    <artifactId>test</artifactId>
+    <version>0.1</version>
+  </parent>
+</project>
\ No newline at end of file
diff --git a/core-it-suite/src/test/resources/mng-6609/pom.xml b/core-it-suite/src/test/resources/mng-6609/pom.xml
new file mode 100644
index 000000000..c7a1bf658
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6609/pom.xml
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.mng6609</groupId>
+  <artifactId>test</artifactId>
+  <version>0.1</version>
+  <packaging>pom</packaging>
+
+  <name>Maven Integration Test :: MNG-6609</name>
+  <description>
+    Test that profiles in the POM can be activated by the special propery "project.packaging" which contains the current project's packaging.
+  </description>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-expression</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <executions>
+          <execution>
+            <phase>validate</phase>
+            <goals>
+              <goal>eval</goal>
+            </goals>
+            <configuration>
+              <outputFile>target/profile.properties</outputFile>
+              <expressions>
+                <expression>project/properties</expression>
+              </expressions>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+  <modules>
+    <module>jar</module>
+    <module>jar-no-packaging</module>
+    <module>war</module>
+  </modules>
+
+  <profiles>
+    <profile>
+      <id>jar</id>
+      <activation>
+        <property>
+          <name>project.packaging</name>
+          <value>jar</value>
+        </property>
+      </activation>
+      <properties>
+        <packaging>jar</packaging>
+      </properties>
+    </profile>
+    <profile>
+      <id>war</id>
+      <activation>
+        <property>
+          <name>project.packaging</name>
+          <value>war</value>
+        </property>
+      </activation>
+      <properties>
+        <packaging>war</packaging>
+      </properties>
+    </profile>
+    <profile>
+      <id>pom</id>
+      <activation>
+        <property>
+          <name>project.packaging</name>
+          <value>pom</value>
+        </property>
+      </activation>
+      <properties>
+        <packaging>pom</packaging>
+      </properties>
+    </profile>
+  </profiles>
+</project>
diff --git a/core-it-suite/src/test/resources/mng-6609/war/pom.xml b/core-it-suite/src/test/resources/mng-6609/war/pom.xml
new file mode 100644
index 000000000..aa4c0fbb4
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6609/war/pom.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>war</artifactId>
+  <version>0.1</version>
+  <packaging>war</packaging>
+
+  <name>Maven Integration Test :: MNG-6609 :: War</name>
+
+  <parent>
+    <groupId>org.apache.maven.its.mng6609</groupId>
+    <artifactId>test</artifactId>
+    <version>0.1</version>
+  </parent>
+</project>
\ No newline at end of file