You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ma...@apache.org on 2022/09/16 12:38:22 UTC

[maven-integration-testing] branch master updated: [MNG-7310] Add a test for MNG-7310 which installs an extension and then builds a multimodule project where one submodule activates the extension, and a submodule which should not activate the extension.

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

martinkanters pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-integration-testing.git


The following commit(s) were added to refs/heads/master by this push:
     new 899326616 [MNG-7310] Add a test for MNG-7310 which installs an extension and then builds a multimodule project where one submodule activates the extension, and a submodule which should not activate the extension.
899326616 is described below

commit 8993266166805a0667679011689f4e5a05eb9ddc
Author: Martin Kanters <ma...@apache.org>
AuthorDate: Thu Dec 23 14:11:30 2021 +0100

    [MNG-7310] Add a test for MNG-7310 which installs an extension and then builds a multimodule project where one submodule activates the extension, and a submodule which should not activate the extension.
    
    This resolves #131.
---
 .../org/apache/maven/it/IntegrationTestSuite.java  |   1 +
 ...310LifecycleActivatedInSpecifiedModuleTest.java |  58 ++++++++++++
 .../extension/pom.xml                              | 104 +++++++++++++++++++++
 .../extension/src/main/java/testmojo/TestMojo.java |  35 +++++++
 .../META-INF/m2e/lifecycle-mapping-metadata.xml    |  17 ++++
 .../main/resources/META-INF/plexus/components.xml  |  41 ++++++++
 .../project/extension-user/pom.xml                 |  47 ++++++++++
 .../project/other-module/pom.xml                   |  34 +++++++
 .../project/pom.xml                                |  42 +++++++++
 9 files changed, 379 insertions(+)

diff --git a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
index a0fcf09a0..f06ca24aa 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
@@ -105,6 +105,7 @@ public class IntegrationTestSuite
         // Tests that don't run stable and need to be fixed
         // -------------------------------------------------------------------------------------------------------------
         // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
+        suite.addTestSuite( MavenITmng7310LifecycleActivatedInSpecifiedModuleTest.class );
         suite.addTestSuite( MavenITmng7474SessionScopeTest.class );
         suite.addTestSuite( MavenITmng7529VersionRangeRepositorySelection.class );
         suite.addTestSuite( MavenITmng7443ConsistencyOfOptionalProjectsAndProfilesTest.class );
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7310LifecycleActivatedInSpecifiedModuleTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7310LifecycleActivatedInSpecifiedModuleTest.java
new file mode 100644
index 000000000..0f63bd7e1
--- /dev/null
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7310LifecycleActivatedInSpecifiedModuleTest.java
@@ -0,0 +1,58 @@
+package org.apache.maven.it;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.it.util.ResourceExtractor;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * An integration test which proves that the bug of MNG-7310 is fixed.
+ * The bug is about loading an extension in a sibling submodule, which ends up failing the build.
+ *
+ * <a href="https://issues.apache.org/jira/browse/MNG-7310">MNG-7310</a>.
+ *
+ */
+public class MavenITmng7310LifecycleActivatedInSpecifiedModuleTest
+    extends AbstractMavenIntegrationTestCase
+{
+
+    public static final String BASE_TEST_DIR = "/mng-7310-lifecycle-activated-in-specified-module";
+
+    public MavenITmng7310LifecycleActivatedInSpecifiedModuleTest()
+    {
+        super( "[4.0.0-alpha-1,)" );
+    }
+
+    public void testItShouldNotLoadAnExtensionInASiblingSubmodule()
+        throws Exception
+    {
+        File extensionTestDir = ResourceExtractor.simpleExtractResources( getClass(), BASE_TEST_DIR + "/extension" );
+        File projectTestDir = ResourceExtractor.simpleExtractResources( getClass(), BASE_TEST_DIR + "/project" );
+
+        Verifier verifier = newVerifier( extensionTestDir.getAbsolutePath(), "remote" );
+        verifier.executeGoal( "install" );
+
+        Verifier verifier2 = newVerifier( projectTestDir.getAbsolutePath() );
+        verifier2.executeGoal( "compile" );
+    }
+}
diff --git a/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/extension/pom.xml b/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/extension/pom.xml
new file mode 100644
index 000000000..ad873b678
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/extension/pom.xml
@@ -0,0 +1,104 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>mng-7310-lifecycle-activated-in-specified-module</groupId>
+  <artifactId>mng-7310-lifecycle-activated-in-specified-module</artifactId>
+  <version>0.1</version>
+
+  <packaging>maven-plugin</packaging>
+
+  <properties>
+    <maven.compiler.target>1.8</maven.compiler.target>
+    <maven.compiler.source>1.8</maven.compiler.source>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugin-tools</groupId>
+      <artifactId>maven-plugin-annotations</artifactId>
+      <version>3.6.4</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>3.6.3</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.eclipse.sisu</groupId>
+        <artifactId>sisu-maven-plugin</artifactId>
+        <version>0.3.5</version>
+        <executions>
+          <execution>
+            <id>generate-index</id>
+            <goals>
+              <goal>main-index</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <artifactId>maven-plugin-plugin</artifactId>
+        <version>3.6.4</version>
+        <configuration>
+          <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+        </configuration>
+        <executions>
+          <execution>
+            <id>generated-helpmojo</id>
+            <goals>
+              <goal>helpmojo</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>generate-descriptor</id>
+            <goals>
+              <goal>descriptor</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-component-metadata</artifactId>
+        <version>2.1.1</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>generate-metadata</goal>
+              <goal>generate-test-metadata</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file
diff --git a/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/extension/src/main/java/testmojo/TestMojo.java b/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/extension/src/main/java/testmojo/TestMojo.java
new file mode 100644
index 000000000..4182e1b4a
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/extension/src/main/java/testmojo/TestMojo.java
@@ -0,0 +1,35 @@
+package testmojo;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Mojo;
+
+@Mojo( name = "test-mojo" )
+public class TestMojo extends AbstractMojo
+{
+
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        getLog().info( "MNG-7310 plugin test-mojo goal executed" );
+    }
+}
diff --git a/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/extension/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml b/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/extension/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
new file mode 100644
index 000000000..b14801d38
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/extension/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
@@ -0,0 +1,17 @@
+<lifecycleMappingMetadata>
+  <pluginExecutions>
+    <pluginExecution>
+      <pluginExecutionFilter>
+        <goals>
+          <goal>test-only</goal>
+        </goals>
+      </pluginExecutionFilter>
+      <action>
+        <execute>
+          <runOnIncremental>true</runOnIncremental>
+          <runOnConfiguration>false</runOnConfiguration>
+        </execute>
+      </action>
+    </pluginExecution>
+  </pluginExecutions>
+</lifecycleMappingMetadata>
diff --git a/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/extension/src/main/resources/META-INF/plexus/components.xml b/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/extension/src/main/resources/META-INF/plexus/components.xml
new file mode 100644
index 000000000..d4e312446
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/extension/src/main/resources/META-INF/plexus/components.xml
@@ -0,0 +1,41 @@
+<?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.
+-->
+
+<component-set>
+  <components>
+    <component>
+      <role>org.apache.maven.lifecycle.Lifecycle</role>
+      <implementation>org.apache.maven.lifecycle.Lifecycle</implementation>
+      <role-hint>test-only</role-hint>
+      <configuration>
+        <id>test-only</id>
+        <phases>
+          <phase>test-only</phase>
+        </phases>
+        <default-phases>
+          <package>
+            mng-7310-lifecycle-activated-in-specified-module:mng-7310-lifecycle-activated-in-specified-module:${project.version}:test-mojo
+          </package>
+        </default-phases>
+      </configuration>
+    </component>
+  </components>
+</component-set>
diff --git a/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/project/extension-user/pom.xml b/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/project/extension-user/pom.xml
new file mode 100644
index 000000000..02cdbdbf5
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/project/extension-user/pom.xml
@@ -0,0 +1,47 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>com.example</groupId>
+    <artifactId>parent</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+  <artifactId>extension-user</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>jar</packaging>
+  <properties>
+    <plugin.version>0.1</plugin.version>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>mng-7310-lifecycle-activated-in-specified-module</groupId>
+        <artifactId>mng-7310-lifecycle-activated-in-specified-module</artifactId>
+        <version>${plugin.version}</version>
+        <extensions>true</extensions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/project/other-module/pom.xml b/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/project/other-module/pom.xml
new file mode 100644
index 000000000..c1863a4b6
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/project/other-module/pom.xml
@@ -0,0 +1,34 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>com.example</groupId>
+    <artifactId>parent</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>demo2</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>jar</packaging>
+</project>
diff --git a/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/project/pom.xml b/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/project/pom.xml
new file mode 100644
index 000000000..5e8d49b2d
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7310-lifecycle-activated-in-specified-module/project/pom.xml
@@ -0,0 +1,42 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>com.example</groupId>
+  <artifactId>parent</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <name>Maven Integration Test :: MNG-7310</name>
+  <description>
+    Build two submodules, where one activates the extension and the other does not.
+    This test proves that the latter module build does not fail because it does not activate that extension.
+  </description>
+
+  <modules>
+    <module>extension-user</module>
+    <module>other-module</module>
+  </modules>
+
+</project>