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 2013/10/31 12:53:06 UTC

git commit: MNG-5530 Introduced IT for mojo execution guice scope

Updated Branches:
  refs/heads/master 78caa74ae -> 2fbb5dde0


MNG-5530 Introduced IT for mojo execution guice scope

Signed-off-by: Igor Fedorenko <ig...@ifedorenko.com>


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

Branch: refs/heads/master
Commit: 2fbb5dde0fcc393c151614c4299efc504978fe78
Parents: 78caa74
Author: Igor Fedorenko <ig...@ifedorenko.com>
Authored: Sun Nov 25 01:49:24 2012 -0500
Committer: Igor Fedorenko <ig...@ifedorenko.com>
Committed: Thu Oct 31 00:23:53 2013 -0400

----------------------------------------------------------------------
 .../apache/maven/it/IntegrationTestSuite.java   |  1 +
 .../MavenITmng5530MojoExecutionScopeTest.java   | 59 ++++++++++++
 .../mng5530-mojo-execution-scope-basic/pom.xml  | 51 +++++++++++
 .../mng5530-mojo-execution-scope-plugin/pom.xml | 95 ++++++++++++++++++++
 .../TestExecutionScopeMojo.java                 | 40 +++++++++
 .../TestExecutionScopedComponent.java           | 81 +++++++++++++++++
 6 files changed, 327 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/2fbb5dde/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 bacc532..29e6bcf 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
@@ -106,6 +106,7 @@ public class IntegrationTestSuite
         // -------------------------------------------------------------------------------------------------------------
         // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
 
+        suite.addTestSuite( MavenITmng5530MojoExecutionScopeTest.class );
         //suite.addTestSuite( MavenITmng5208EventSpyParallelTest.class );
         
         

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/2fbb5dde/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5530MojoExecutionScopeTest.java
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5530MojoExecutionScopeTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5530MojoExecutionScopeTest.java
new file mode 100644
index 0000000..2b14720
--- /dev/null
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5530MojoExecutionScopeTest.java
@@ -0,0 +1,59 @@
+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;
+
+public class MavenITmng5530MojoExecutionScopeTest
+    extends AbstractMavenIntegrationTestCase
+{
+    public MavenITmng5530MojoExecutionScopeTest()
+    {
+        super( "[3.1.2,)" );
+    }
+
+    public void test_copyfiles()
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng5530-mojo-execution-scope" );
+        File pluginDir = new File( testDir, "mng5530-mojo-execution-scope-plugin" );
+        File projectDir = new File( testDir, "mng5530-mojo-execution-scope-basic" );
+
+        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( "package" );
+        verifier.resetStreams();
+        verifier.verifyErrorFreeLog();
+
+        verifier.assertFilePresent( "target/execution-executed.txt" );
+        verifier.assertFilePresent( "target/execution-committed.txt" );
+        verifier.assertFilePresent( "target/execution-disposed.txt" );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/2fbb5dde/core-it-suite/src/test/resources/mng5530-mojo-execution-scope/mng5530-mojo-execution-scope-basic/pom.xml
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng5530-mojo-execution-scope/mng5530-mojo-execution-scope-basic/pom.xml b/core-it-suite/src/test/resources/mng5530-mojo-execution-scope/mng5530-mojo-execution-scope-basic/pom.xml
new file mode 100644
index 0000000..025d0b5
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng5530-mojo-execution-scope/mng5530-mojo-execution-scope-basic/pom.xml
@@ -0,0 +1,51 @@
+<?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>io.tesla.its.mojoexecutionscope</groupId>
+  <artifactId>mng5530-mojo-execution-scope-basic</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>io.tesla.its.mojoexecutionscope</groupId>
+        <artifactId>mng5530-mojo-execution-scope-plugin</artifactId>
+        <version>0.1</version>
+        <extensions>true</extensions>
+        <executions>
+          <execution>
+            <id>test-execution-scope</id>
+            <goals>
+              <goal>test-execution-scope</goal>
+            </goals>
+            <phase>process-resources</phase>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/2fbb5dde/core-it-suite/src/test/resources/mng5530-mojo-execution-scope/mng5530-mojo-execution-scope-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng5530-mojo-execution-scope/mng5530-mojo-execution-scope-plugin/pom.xml b/core-it-suite/src/test/resources/mng5530-mojo-execution-scope/mng5530-mojo-execution-scope-plugin/pom.xml
new file mode 100644
index 0000000..b9f935b
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng5530-mojo-execution-scope/mng5530-mojo-execution-scope-plugin/pom.xml
@@ -0,0 +1,95 @@
+<?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>io.tesla.its.mojoexecutionscope</groupId>
+  <artifactId>mng5530-mojo-execution-scope-plugin</artifactId>
+  <version>0.1</version>
+  <packaging>maven-plugin</packaging>
+
+  <properties>
+    <maven-version>3.1.2-SNAPSHOT</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>
+      <plugin>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-component-metadata</artifactId>
+        <version>1.5.5</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>generate-metadata</goal>
+              <goal>generate-test-metadata</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/2fbb5dde/core-it-suite/src/test/resources/mng5530-mojo-execution-scope/mng5530-mojo-execution-scope-plugin/src/main/java/org/apache/maven/its/mng5530/mojoexecutionscope/TestExecutionScopeMojo.java
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng5530-mojo-execution-scope/mng5530-mojo-execution-scope-plugin/src/main/java/org/apache/maven/its/mng5530/mojoexecutionscope/TestExecutionScopeMojo.java b/core-it-suite/src/test/resources/mng5530-mojo-execution-scope/mng5530-mojo-execution-scope-plugin/src/main/java/org/apache/maven/its/mng5530/mojoexecutionscope/TestExecutionScopeMojo.java
new file mode 100644
index 0000000..24d5c8a
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng5530-mojo-execution-scope/mng5530-mojo-execution-scope-plugin/src/main/java/org/apache/maven/its/mng5530/mojoexecutionscope/TestExecutionScopeMojo.java
@@ -0,0 +1,40 @@
+package org.apache.maven.its.mng5530.mojoexecutionscope;
+
+/*
+ * 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-execution-scope
+ */
+public class TestExecutionScopeMojo
+    extends AbstractMojo
+{
+    /** @component */
+    private TestExecutionScopedComponent executionScopedComponent;
+
+    public void execute()
+        throws MojoExecutionException, MojoFailureException
+    {
+        executionScopedComponent.recordExecute();
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/2fbb5dde/core-it-suite/src/test/resources/mng5530-mojo-execution-scope/mng5530-mojo-execution-scope-plugin/src/main/java/org/apache/maven/its/mng5530/mojoexecutionscope/TestExecutionScopedComponent.java
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng5530-mojo-execution-scope/mng5530-mojo-execution-scope-plugin/src/main/java/org/apache/maven/its/mng5530/mojoexecutionscope/TestExecutionScopedComponent.java b/core-it-suite/src/test/resources/mng5530-mojo-execution-scope/mng5530-mojo-execution-scope-plugin/src/main/java/org/apache/maven/its/mng5530/mojoexecutionscope/TestExecutionScopedComponent.java
new file mode 100644
index 0000000..50c1420
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng5530-mojo-execution-scope/mng5530-mojo-execution-scope-plugin/src/main/java/org/apache/maven/its/mng5530/mojoexecutionscope/TestExecutionScopedComponent.java
@@ -0,0 +1,81 @@
+package org.apache.maven.its.mng5530.mojoexecutionscope;
+
+/*
+ * 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 javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.execution.scope.MojoExecutionListener;
+import org.apache.maven.execution.scope.MojoExecutionScoped;
+import org.apache.maven.plugin.MojoExecution;
+import org.apache.maven.project.MavenProject;
+
+@Named
+@MojoExecutionScoped
+public class TestExecutionScopedComponent
+    implements MojoExecutionListener
+{
+    private final File basedir;
+
+    private MavenSession session;
+
+    private MojoExecution execution;
+
+    @Inject
+    public TestExecutionScopedComponent( MavenSession session, MavenProject project, MojoExecution execution )
+    {
+        this.session = session;
+        this.execution = execution;
+        this.basedir = new File( project.getBuild().getDirectory() );
+    }
+
+    public void recordExecute()
+    {
+        touch( new File( basedir, "execution-executed.txt" ) );
+    }
+
+    private void touch( File file )
+    {
+        file.getParentFile().mkdirs();
+        try
+        {
+            new FileOutputStream( file ).close();
+        }
+        catch ( IOException e )
+        {
+            // ignore
+        }
+    }
+
+    public void afterMojoExecutionAlways()
+    {
+        touch( new File( basedir, "execution-disposed.txt" ) );
+    }
+
+    public void afterMojoExecutionSuccess()
+    {
+        touch( new File( basedir, "execution-committed.txt" ) );
+    }
+}