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 2014/12/25 19:38:59 UTC

maven-integration-testing git commit: MNG-5742 fixed duplicate plugin realms when extensions=true

Repository: maven-integration-testing
Updated Branches:
  refs/heads/master 858523d90 -> d4a340e62


MNG-5742 fixed duplicate plugin realms when extensions=true

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/d4a340e6
Tree: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/tree/d4a340e6
Diff: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/diff/d4a340e6

Branch: refs/heads/master
Commit: d4a340e6202d486c57adc2019924c03e28ffc975
Parents: 858523d
Author: Igor Fedorenko <if...@apache.org>
Authored: Thu Dec 25 13:20:11 2014 -0500
Committer: Igor Fedorenko <if...@apache.org>
Committed: Thu Dec 25 13:20:11 2014 -0500

----------------------------------------------------------------------
 ...nITmng5742BuildExtensionClassloaderTest.java | 61 +++++++++++++
 .../plugin/pom.xml                              | 82 ++++++++++++++++++
 .../BuildExtensionClassloaderComponent.java     | 91 ++++++++++++++++++++
 .../plugin/BuildExtensionClassloaderMojo.java   | 46 ++++++++++
 .../project/pom.xml                             | 49 +++++++++++
 5 files changed, 329 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/d4a340e6/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5742BuildExtensionClassloaderTest.java
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5742BuildExtensionClassloaderTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5742BuildExtensionClassloaderTest.java
new file mode 100644
index 0000000..64f093c
--- /dev/null
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5742BuildExtensionClassloaderTest.java
@@ -0,0 +1,61 @@
+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 MavenITmng5742BuildExtensionClassloaderTest
+    extends AbstractMavenIntegrationTestCase
+{
+
+    public MavenITmng5742BuildExtensionClassloaderTest()
+    {
+        super( "[3.2.6-SNAPSHOT,)" );
+    }
+
+    public void testBuildExtensionClassloader()
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5742-build-extension-classloader" );
+        File pluginDir = new File( testDir, "plugin" );
+        File projectDir = new File( testDir, "project" );
+
+        Verifier verifier;
+
+        // install the test plugin
+        verifier = newVerifier( pluginDir.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/execution-success.txt" );
+
+        String actual = FileUtils.fileRead( new File( projectDir, "target/execution-success.txt" ) );
+        assertEquals( "executed", actual );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/d4a340e6/core-it-suite/src/test/resources/mng-5742-build-extension-classloader/plugin/pom.xml
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng-5742-build-extension-classloader/plugin/pom.xml b/core-it-suite/src/test/resources/mng-5742-build-extension-classloader/plugin/pom.xml
new file mode 100644
index 0000000..e166520
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-5742-build-extension-classloader/plugin/pom.xml
@@ -0,0 +1,82 @@
+<?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-5742-build-extension-classloader</groupId>
+  <artifactId>mng-5742-build-extension-classloader-plugin</artifactId>
+  <version>0.1</version>
+  <packaging>maven-plugin</packaging>
+
+  <properties>
+    <maven-version>3.2.1</maven-version>
+  </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.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.0.2</version>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+      <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/d4a340e6/core-it-suite/src/test/resources/mng-5742-build-extension-classloader/plugin/src/main/java/org/apache/maven/its/mng5742/build/extension/classloader/plugin/BuildExtensionClassloaderComponent.java
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng-5742-build-extension-classloader/plugin/src/main/java/org/apache/maven/its/mng5742/build/extension/classloader/plugin/BuildExtensionClassloaderComponent.java b/core-it-suite/src/test/resources/mng-5742-build-extension-classloader/plugin/src/main/java/org/apache/maven/its/mng5742/build/extension/classloader/plugin/BuildExtensionClassloaderComponent.java
new file mode 100644
index 0000000..1a9a446
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-5742-build-extension-classloader/plugin/src/main/java/org/apache/maven/its/mng5742/build/extension/classloader/plugin/BuildExtensionClassloaderComponent.java
@@ -0,0 +1,91 @@
+package org.apache.maven.its.mng5742.build.extension.classloader.plugin;
+
+/*
+ * 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 java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.apache.maven.AbstractMavenLifecycleParticipant;
+import org.apache.maven.MavenExecutionException;
+import org.apache.maven.execution.MavenSession;
+
+@Named
+@Singleton
+public class BuildExtensionClassloaderComponent
+    extends AbstractMavenLifecycleParticipant
+{
+    public static final String FILE_PATH = "target/execution-success.txt";
+
+    @Inject
+    public BuildExtensionClassloaderComponent()
+    {
+    }
+
+    private final AtomicInteger pluginExecutionCount = new AtomicInteger();
+
+    private final AtomicInteger extensionExecutionCount = new AtomicInteger();
+
+    public void invokedFromMojo()
+    {
+        pluginExecutionCount.incrementAndGet();
+    }
+
+    @Override
+    public void afterSessionEnd( MavenSession session )
+        throws MavenExecutionException
+    {
+        if ( extensionExecutionCount.incrementAndGet() != 1 )
+        {
+            throw new IllegalStateException();
+        }
+
+        if ( pluginExecutionCount.intValue() != 1 )
+        {
+            throw new IllegalStateException();
+        }
+
+        try
+        {
+            File file = new File( session.getTopLevelProject().getBasedir(), FILE_PATH );
+            file.getParentFile().mkdirs();
+            Writer w = new OutputStreamWriter( new FileOutputStream( file, true ), "UTF-8" );
+            try
+            {
+                w.write( "executed" );
+            }
+            finally
+            {
+                w.close();
+            }
+        }
+        catch ( IOException e )
+        {
+            throw new MavenExecutionException( e.getMessage(), e );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/d4a340e6/core-it-suite/src/test/resources/mng-5742-build-extension-classloader/plugin/src/main/java/org/apache/maven/its/mng5742/build/extension/classloader/plugin/BuildExtensionClassloaderMojo.java
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng-5742-build-extension-classloader/plugin/src/main/java/org/apache/maven/its/mng5742/build/extension/classloader/plugin/BuildExtensionClassloaderMojo.java b/core-it-suite/src/test/resources/mng-5742-build-extension-classloader/plugin/src/main/java/org/apache/maven/its/mng5742/build/extension/classloader/plugin/BuildExtensionClassloaderMojo.java
new file mode 100644
index 0000000..bd12242
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-5742-build-extension-classloader/plugin/src/main/java/org/apache/maven/its/mng5742/build/extension/classloader/plugin/BuildExtensionClassloaderMojo.java
@@ -0,0 +1,46 @@
+package org.apache.maven.its.mng5742.build.extension.classloader.plugin;
+
+/*
+ * 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.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * @goal test
+ */
+public class BuildExtensionClassloaderMojo
+    extends AbstractMojo
+{
+    /** @component */
+    private BuildExtensionClassloaderComponent component;
+
+    /** @parameter default-value="${project.basedir}" */
+    private File basedir;
+
+    public void execute()
+        throws MojoExecutionException, MojoFailureException
+    {
+        new File( basedir, BuildExtensionClassloaderComponent.FILE_PATH ).delete();
+        component.invokedFromMojo();
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/d4a340e6/core-it-suite/src/test/resources/mng-5742-build-extension-classloader/project/pom.xml
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng-5742-build-extension-classloader/project/pom.xml b/core-it-suite/src/test/resources/mng-5742-build-extension-classloader/project/pom.xml
new file mode 100644
index 0000000..faf4202
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-5742-build-extension-classloader/project/pom.xml
@@ -0,0 +1,49 @@
+<?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-5742-build-extension-classloader</groupId>
+  <artifactId>mng-5742-build-extension-classloader-project</artifactId>
+  <version>0.1</version>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>mng-5742-build-extension-classloader</groupId>
+        <artifactId>mng-5742-build-extension-classloader-plugin</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>