You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by if...@apache.org on 2017/04/12 00:03:55 UTC

maven-integration-testing git commit: MNG-6209 better executeMojo thread context classloader

Repository: maven-integration-testing
Updated Branches:
  refs/heads/MNG-6209_multiple-build-extensions [created] f476ac3d4


MNG-6209 better executeMojo thread context classloader

Signed-off-by: Igor Fedorenko <if...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/commit/f476ac3d
Tree: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/tree/f476ac3d
Diff: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/diff/f476ac3d

Branch: refs/heads/MNG-6209_multiple-build-extensions
Commit: f476ac3d4567312dcd9ea0975ce5cba84ddcb1ec
Parents: 3941c79
Author: Igor Fedorenko <if...@apache.org>
Authored: Tue Apr 11 08:03:08 2017 -0700
Committer: Igor Fedorenko <if...@apache.org>
Committed: Tue Apr 11 08:03:44 2017 -0700

----------------------------------------------------------------------
 .../apache/maven/it/IntegrationTestSuite.java   |  1 +
 .../MavenITmng6209MultipleBuildExtensions.java  | 65 +++++++++++++++
 .../plugin-a/pom.xml                            | 75 +++++++++++++++++
 .../plugina/BuildExtensionAComponent.java       | 88 ++++++++++++++++++++
 .../extensions/plugina/BuildExtensionAMojo.java | 36 ++++++++
 .../plugin-b/pom.xml                            | 75 +++++++++++++++++
 .../extensions/pluginb/BuildExtensionBMojo.java | 36 ++++++++
 .../project/pom.xml                             | 64 ++++++++++++++
 8 files changed, 440 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/f476ac3d/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
----------------------------------------------------------------------
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 40163f5..35ce262 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
@@ -695,6 +695,7 @@ public class IntegrationTestSuite
         suite.addTestSuite( MavenIT0010DependencyClosureResolutionTest.class );
         suite.addTestSuite( MavenIT0009GoalConfigurationTest.class );
         suite.addTestSuite( MavenIT0008SimplePluginTest.class );
+        suite.addTestSuite( MavenITmng6209MultipleBuildExtensions.class );
 
         /*
          * Add tests in reverse alpha order above.

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/f476ac3d/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6209MultipleBuildExtensions.java
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6209MultipleBuildExtensions.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6209MultipleBuildExtensions.java
new file mode 100644
index 0000000..5b0c60d
--- /dev/null
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6209MultipleBuildExtensions.java
@@ -0,0 +1,65 @@
+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 java.io.File;
+
+import org.apache.maven.it.util.ResourceExtractor;
+import org.apache.maven.shared.utils.io.FileUtils;
+
+public class MavenITmng6209MultipleBuildExtensions extends AbstractMavenIntegrationTestCase {
+
+  public MavenITmng6209MultipleBuildExtensions() {
+    super("(3.5.0,)");
+  }
+
+  public void testBuildExtensionClassloader() throws Exception {
+    File testDir =
+        ResourceExtractor.simpleExtractResources(getClass(), "/MNG-6209-multiple-build-extensions");
+    File pluginADir = new File(testDir, "plugin-a");
+    File pluginBDir = new File(testDir, "plugin-b");
+    File projectDir = new File(testDir, "project");
+
+    Verifier verifier;
+
+    // install the test plugins
+    verifier = newVerifier(pluginADir.getAbsolutePath(), "remote");
+    verifier.executeGoal("install");
+    verifier.resetStreams();
+    verifier.verifyErrorFreeLog();
+    //
+    verifier = newVerifier(pluginBDir.getAbsolutePath(), "remote");
+    verifier.executeGoal("install");
+    verifier.resetStreams();
+    verifier.verifyErrorFreeLog();
+
+    // build the test project
+    verifier = newVerifier(projectDir.getAbsolutePath(), "remote");
+    verifier.executeGoal("validate");
+    verifier.resetStreams();
+    verifier.verifyErrorFreeLog();
+    verifier.assertFilePresent("target/executions.txt");
+
+    String[] executions = FileUtils.fileReadArray(new File(projectDir, "target/executions.txt"));
+    assertEquals(2, executions.length);
+    assertEquals(
+        "mng-6209-multiple-build-extensions:mng-6209-multiple-build-extensions-plugin-a:0.1:test {execution: test}",
+        executions[0]);
+    assertEquals(
+        "mng-6209-multiple-build-extensions:mng-6209-multiple-build-extensions-plugin-b:0.1:test {execution: test}",
+        executions[1]);
+  }
+}

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/f476ac3d/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-a/pom.xml
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-a/pom.xml b/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-a/pom.xml
new file mode 100644
index 0000000..48a4709
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-a/pom.xml
@@ -0,0 +1,75 @@
+<?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/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>mng-6209-multiple-build-extensions</groupId>
+  <artifactId>mng-6209-multiple-build-extensions-plugin-a</artifactId>
+  <version>0.1</version>
+  <packaging>maven-plugin</packaging>
+
+  <properties>
+    <maven-version>3.2.1</maven-version>
+    <maven.compiler.source>1.5</maven.compiler.source>
+    <maven.compiler.target>1.5</maven.compiler.target>    
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>${maven-version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-model</artifactId>
+      <version>${maven-version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-core</artifactId>
+      <version>${maven-version}</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.sonatype.plugins</groupId>
+        <artifactId>sisu-maven-plugin</artifactId>
+        <version>1.1</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>main-index</goal>
+              <goal>test-index</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/f476ac3d/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-a/src/main/java/org/apache/maven/its/mng6209/multiple/build/extensions/plugina/BuildExtensionAComponent.java
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-a/src/main/java/org/apache/maven/its/mng6209/multiple/build/extensions/plugina/BuildExtensionAComponent.java b/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-a/src/main/java/org/apache/maven/its/mng6209/multiple/build/extensions/plugina/BuildExtensionAComponent.java
new file mode 100644
index 0000000..93350dd
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-a/src/main/java/org/apache/maven/its/mng6209/multiple/build/extensions/plugina/BuildExtensionAComponent.java
@@ -0,0 +1,88 @@
+package org.apache.maven.its.mng6209.multiple.build.extensions.plugina;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.Set;
+import java.util.TreeSet;
+
+/*
+ * 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 javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.apache.maven.AbstractMavenLifecycleParticipant;
+import org.apache.maven.MavenExecutionException;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.execution.MojoExecutionEvent;
+import org.apache.maven.execution.MojoExecutionListener;
+import org.apache.maven.plugin.MojoExecutionException;
+
+@Named
+@Singleton
+public class BuildExtensionAComponent
+    extends AbstractMavenLifecycleParticipant
+    implements MojoExecutionListener
+{
+    public static final String FILE_PATH = "target/executions.txt";
+
+    private final Set<String> executions = new TreeSet<String>();
+
+    @Override
+    public void afterSessionEnd( MavenSession session )
+        throws MavenExecutionException
+    {
+        try
+        {
+            File file = new File( session.getTopLevelProject().getBasedir(), FILE_PATH );
+            file.getParentFile().mkdirs();
+            Writer w = new OutputStreamWriter( new FileOutputStream( file, false ), "UTF-8" );
+            try
+            {
+                for (String execution : executions)
+                {
+                    w.write( execution + "\n" );
+                }
+            }
+            finally
+            {
+                w.close();
+            }
+        }
+        catch ( IOException e )
+        {
+            throw new RuntimeException( e.getMessage(), e );
+        }
+
+    }
+
+    public void beforeMojoExecution( MojoExecutionEvent event )
+        throws MojoExecutionException
+    {
+        executions.add( event.getExecution().toString() );
+    }
+
+    public void afterMojoExecutionSuccess( MojoExecutionEvent event )
+        throws MojoExecutionException
+    {
+    }
+
+    public void afterExecutionFailure( MojoExecutionEvent event )
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/f476ac3d/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-a/src/main/java/org/apache/maven/its/mng6209/multiple/build/extensions/plugina/BuildExtensionAMojo.java
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-a/src/main/java/org/apache/maven/its/mng6209/multiple/build/extensions/plugina/BuildExtensionAMojo.java b/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-a/src/main/java/org/apache/maven/its/mng6209/multiple/build/extensions/plugina/BuildExtensionAMojo.java
new file mode 100644
index 0000000..73f5553
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-a/src/main/java/org/apache/maven/its/mng6209/multiple/build/extensions/plugina/BuildExtensionAMojo.java
@@ -0,0 +1,36 @@
+package org.apache.maven.its.mng6209.multiple.build.extensions.plugina;
+
+/*
+ * 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;
+
+/**
+ * @goal test
+ */
+public class BuildExtensionAMojo
+    extends AbstractMojo
+{
+    public void execute()
+        throws MojoExecutionException, MojoFailureException
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/f476ac3d/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-b/pom.xml
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-b/pom.xml b/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-b/pom.xml
new file mode 100644
index 0000000..2b97ace
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-b/pom.xml
@@ -0,0 +1,75 @@
+<?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/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>mng-6209-multiple-build-extensions</groupId>
+  <artifactId>mng-6209-multiple-build-extensions-plugin-b</artifactId>
+  <version>0.1</version>
+  <packaging>maven-plugin</packaging>
+
+  <properties>
+    <maven-version>3.2.1</maven-version>
+    <maven.compiler.source>1.5</maven.compiler.source>
+    <maven.compiler.target>1.5</maven.compiler.target>    
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>${maven-version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-model</artifactId>
+      <version>${maven-version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-core</artifactId>
+      <version>${maven-version}</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.sonatype.plugins</groupId>
+        <artifactId>sisu-maven-plugin</artifactId>
+        <version>1.1</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>main-index</goal>
+              <goal>test-index</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/f476ac3d/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-b/src/main/java/org/apache/maven/its/mng6209/multiple/build/extensions/pluginb/BuildExtensionBMojo.java
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-b/src/main/java/org/apache/maven/its/mng6209/multiple/build/extensions/pluginb/BuildExtensionBMojo.java b/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-b/src/main/java/org/apache/maven/its/mng6209/multiple/build/extensions/pluginb/BuildExtensionBMojo.java
new file mode 100644
index 0000000..b57ad5a
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/plugin-b/src/main/java/org/apache/maven/its/mng6209/multiple/build/extensions/pluginb/BuildExtensionBMojo.java
@@ -0,0 +1,36 @@
+package org.apache.maven.its.mng6209.multiple.build.extensions.pluginb;
+
+/*
+ * 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;
+
+/**
+ * @goal test
+ */
+public class BuildExtensionBMojo
+    extends AbstractMojo
+{
+    public void execute()
+        throws MojoExecutionException, MojoFailureException
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/f476ac3d/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/project/pom.xml
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/project/pom.xml b/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/project/pom.xml
new file mode 100644
index 0000000..313116f
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6209-multiple-build-extensions/project/pom.xml
@@ -0,0 +1,64 @@
+<?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/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>mng-6209-multiple-build-extensions</groupId>
+  <artifactId>mng-6209-multiple-build-extensions-project</artifactId>
+  <version>0.1</version>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>mng-6209-multiple-build-extensions</groupId>
+        <artifactId>mng-6209-multiple-build-extensions-plugin-a</artifactId>
+        <version>0.1</version>
+        <extensions>true</extensions>
+        <executions>
+          <execution>
+            <id>test</id>
+            <goals>
+              <goal>test</goal>
+            </goals>
+            <phase>validate</phase>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>mng-6209-multiple-build-extensions</groupId>
+        <artifactId>mng-6209-multiple-build-extensions-plugin-b</artifactId>
+        <version>0.1</version>
+        <extensions>true</extensions>
+        <executions>
+          <execution>
+            <id>test</id>
+            <goals>
+              <goal>test</goal>
+            </goals>
+            <phase>validate</phase>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>