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/07/08 11:52:09 UTC

[1/4] git commit: MPLUGINTESTING-43 TestResources#create convenience method

Repository: maven-plugin-testing
Updated Branches:
  refs/heads/master 3cd5f47c5 -> bc3583495


MPLUGINTESTING-43 TestResources#create convenience method

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


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

Branch: refs/heads/master
Commit: 1f5a4769859d20363f0924418017fe92a9bba297
Parents: 3cd5f47
Author: Igor Fedorenko <if...@apache.org>
Authored: Tue Jul 8 12:47:22 2014 +0400
Committer: Igor Fedorenko <if...@apache.org>
Committed: Tue Jul 8 13:48:48 2014 +0400

----------------------------------------------------------------------
 .../plugin/testing/resources/TestResources.java  | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/blob/1f5a4769/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/resources/TestResources.java
----------------------------------------------------------------------
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/resources/TestResources.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/resources/TestResources.java
index 378c03e..c3f41e7 100644
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/resources/TestResources.java
+++ b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/resources/TestResources.java
@@ -171,4 +171,23 @@ public class TestResources
         Assert.assertTrue( "delete " + path, new File( basedir, path ).delete() );
     }
 
+    /**
+     * @since 3.2.0
+     */
+    public static void create( File basedir, String... paths )
+        throws IOException
+    {
+        if ( paths == null || paths.length == 0 )
+        {
+            throw new IllegalArgumentException();
+        }
+        for ( String path : paths )
+        {
+            File file = new File( basedir, path );
+            Assert.assertTrue( file.getParentFile().mkdirs() );
+            file.createNewFile();
+            Assert.assertTrue( file.isFile() && file.canRead() );
+        }
+    }
+
 }


[3/4] git commit: new version 3.2.0-SNAPSHOT to signify minimal maven 3.2.1

Posted by if...@apache.org.
new version 3.2.0-SNAPSHOT to signify minimal maven 3.2.1

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


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

Branch: refs/heads/master
Commit: bc35834955f33265258b1cfd9f108713d47984b2
Parents: 4636108
Author: Igor Fedorenko <if...@apache.org>
Authored: Tue Jul 8 12:57:35 2014 +0400
Committer: Igor Fedorenko <if...@apache.org>
Committed: Tue Jul 8 13:49:00 2014 +0400

----------------------------------------------------------------------
 maven-plugin-testing-harness/pom.xml | 2 +-
 maven-plugin-testing-tools/pom.xml   | 2 +-
 maven-test-tools/pom.xml             | 2 +-
 pom.xml                              | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/blob/bc358349/maven-plugin-testing-harness/pom.xml
----------------------------------------------------------------------
diff --git a/maven-plugin-testing-harness/pom.xml b/maven-plugin-testing-harness/pom.xml
index 3145627..79fe096 100644
--- a/maven-plugin-testing-harness/pom.xml
+++ b/maven-plugin-testing-harness/pom.xml
@@ -25,7 +25,7 @@ under the License.
   <parent>
     <groupId>org.apache.maven.plugin-testing</groupId>
     <artifactId>maven-plugin-testing</artifactId>
-    <version>3.1.1-SNAPSHOT</version>
+    <version>3.2.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>maven-plugin-testing-harness</artifactId>

http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/blob/bc358349/maven-plugin-testing-tools/pom.xml
----------------------------------------------------------------------
diff --git a/maven-plugin-testing-tools/pom.xml b/maven-plugin-testing-tools/pom.xml
index 92f7e9f..c19d22b 100644
--- a/maven-plugin-testing-tools/pom.xml
+++ b/maven-plugin-testing-tools/pom.xml
@@ -25,7 +25,7 @@ under the License.
   <parent>
     <groupId>org.apache.maven.plugin-testing</groupId>
     <artifactId>maven-plugin-testing</artifactId>
-    <version>3.1.1-SNAPSHOT</version>
+    <version>3.2.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>maven-plugin-testing-tools</artifactId>

http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/blob/bc358349/maven-test-tools/pom.xml
----------------------------------------------------------------------
diff --git a/maven-test-tools/pom.xml b/maven-test-tools/pom.xml
index 60a1ed9..33290ee 100644
--- a/maven-test-tools/pom.xml
+++ b/maven-test-tools/pom.xml
@@ -25,7 +25,7 @@ under the License.
   <parent>
     <groupId>org.apache.maven.plugin-testing</groupId>
     <artifactId>maven-plugin-testing</artifactId>
-    <version>3.1.1-SNAPSHOT</version>
+    <version>3.2.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>maven-test-tools</artifactId>

http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/blob/bc358349/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a2ebed2..1cbd03c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,7 +31,7 @@ under the License.
 
   <groupId>org.apache.maven.plugin-testing</groupId>
   <artifactId>maven-plugin-testing</artifactId>
-  <version>3.1.1-SNAPSHOT</version>
+  <version>3.2.0-SNAPSHOT</version>
   <packaging>pom</packaging>
 
   <name>Maven Plugin Testing</name>


[4/4] git commit: MPLUGINTESTING-42 on-the-fly mojo execution configuration

Posted by if...@apache.org.
MPLUGINTESTING-42 on-the-fly mojo execution configuration

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


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

Branch: refs/heads/master
Commit: 46361087de813bc38004833d52cae7d766bf8e9d
Parents: 3c981e5
Author: Igor Fedorenko <if...@apache.org>
Authored: Tue Jul 8 12:55:09 2014 +0400
Committer: Igor Fedorenko <if...@apache.org>
Committed: Tue Jul 8 13:49:00 2014 +0400

----------------------------------------------------------------------
 .../maven/plugin/testing/MojoParameters.java    | 37 ++++++++++++++++++++
 .../apache/maven/plugin/testing/MojoRule.java   | 28 +++++++++++++++
 2 files changed, 65 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/blob/46361087/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/MojoParameters.java
----------------------------------------------------------------------
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/MojoParameters.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/MojoParameters.java
new file mode 100644
index 0000000..7412bc4
--- /dev/null
+++ b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/MojoParameters.java
@@ -0,0 +1,37 @@
+package org.apache.maven.plugin.testing;
+
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+
+/*
+ * 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.
+ */
+
+/**
+ * Static helpers to create and manipulate mojo execution configuration parameters
+ * 
+ * @since 3.2.0
+ */
+public class MojoParameters
+{
+    public static Xpp3Dom newParameter( String name, String value )
+    {
+        Xpp3Dom child = new Xpp3Dom( name );
+        child.setValue( value );
+        return child;
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/blob/46361087/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/MojoRule.java
----------------------------------------------------------------------
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/MojoRule.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/MojoRule.java
index a8c2db8..d4d57f0 100644
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/MojoRule.java
+++ b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/MojoRule.java
@@ -367,6 +367,34 @@ public class MojoRule
     /**
      * @since 3.2.0
      */
+    public void executeMojo( MavenProject project, String goal, Xpp3Dom... parameters )
+        throws Exception
+    {
+        MavenSession session = newMavenSession( project );
+        executeMojo( session, project, goal, parameters );
+    }
+
+    /**
+     * @since 3.2.0
+     */
+    public void executeMojo( MavenSession session, MavenProject project, String goal, Xpp3Dom... parameters )
+        throws Exception
+    {
+        MojoExecution execution = newMojoExecution( goal );
+        if ( parameters != null )
+        {
+            Xpp3Dom configuration = execution.getConfiguration();
+            for ( Xpp3Dom parameter : parameters )
+            {
+                configuration.addChild( parameter );
+            }
+        }
+        executeMojo( session, project, execution );
+    }
+
+    /**
+     * @since 3.2.0
+     */
     public void executeMojo( MavenSession session, MavenProject project, MojoExecution execution )
         throws Exception
     {


[2/4] git commit: MPLUGINTESTING-41 bind and manage SessionScope and MojoExecutionScope

Posted by if...@apache.org.
MPLUGINTESTING-41 bind and manage SessionScope and MojoExecutionScope

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


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

Branch: refs/heads/master
Commit: 3c981e52f5aff2118c2f9306c05c7bf87537dbc7
Parents: 1f5a476
Author: Igor Fedorenko <if...@apache.org>
Authored: Tue Jul 8 12:53:52 2014 +0400
Committer: Igor Fedorenko <if...@apache.org>
Committed: Tue Jul 8 13:49:00 2014 +0400

----------------------------------------------------------------------
 .../plugin/testing/AbstractMojoTestCase.java    | 16 +++++++
 .../apache/maven/plugin/testing/MojoRule.java   | 49 +++++++++++++++++++-
 pom.xml                                         |  2 +-
 3 files changed, 65 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/blob/3c981e52/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java
----------------------------------------------------------------------
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java
index 9b49e71..91edd5e 100644
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java
+++ b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java
@@ -42,6 +42,8 @@ import org.apache.maven.execution.DefaultMavenExecutionResult;
 import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.execution.MavenExecutionResult;
 import org.apache.maven.execution.MavenSession;
+import org.apache.maven.execution.scope.MojoExecutionScoped;
+import org.apache.maven.execution.scope.internal.MojoExecutionScope;
 import org.apache.maven.lifecycle.internal.MojoDescriptorCreator;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.monitor.logging.DefaultLog;
@@ -78,6 +80,7 @@ import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
 
+import com.google.inject.AbstractModule;
 import com.google.inject.Module;
 
 /**
@@ -223,6 +226,19 @@ public abstract class AbstractMojoTestCase
         try
         {
             List<Module> modules = new ArrayList<Module>();
+            modules.add( new AbstractModule()
+            {
+                @Override
+                protected void configure()
+                {
+                    // execution scope bindings (core binds these in plugin realm injector only)
+                    MojoExecutionScope executionScope = new MojoExecutionScope();
+                    bindScope( MojoExecutionScoped.class, executionScope );
+                    bind( MojoExecutionScope.class ).toInstance( executionScope );
+                    bind( MavenProject.class ).toProvider( MojoExecutionScope.<MavenProject> seededKeyProvider() ).in( executionScope );
+                    bind( MojoExecution.class ).toProvider( MojoExecutionScope.<MojoExecution> seededKeyProvider() ).in( executionScope );
+                }
+            } );
             addGuiceModules( modules );
             container = new DefaultPlexusContainer( cc, modules.toArray( new Module[modules.size()] ) );
         }

http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/blob/3c981e52/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/MojoRule.java
----------------------------------------------------------------------
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/MojoRule.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/MojoRule.java
index 30d2073..a8c2db8 100644
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/MojoRule.java
+++ b/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/MojoRule.java
@@ -23,9 +23,13 @@ import java.io.File;
 import java.io.InputStream;
 import java.util.Map;
 
+import org.apache.maven.SessionScope;
 import org.apache.maven.execution.DefaultMavenExecutionRequest;
 import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.execution.MavenSession;
+import org.apache.maven.execution.MojoExecutionEvent;
+import org.apache.maven.execution.MojoExecutionListener;
+import org.apache.maven.execution.scope.internal.MojoExecutionScope;
 import org.apache.maven.plugin.Mojo;
 import org.apache.maven.plugin.MojoExecution;
 import org.apache.maven.project.MavenProject;
@@ -333,7 +337,10 @@ public class MojoRule
     public void executeMojo( File basedir, String goal )
         throws Exception
     {
-        lookupConfiguredMojo( basedir, goal ).execute();
+        MavenProject project = readMavenProject( basedir );
+        MavenSession session = newMavenSession( project );
+        MojoExecution execution = newMojoExecution( goal );
+        executeMojo( session, project, execution );
     }
 
     /**
@@ -357,4 +364,44 @@ public class MojoRule
         return getContainer().lookup( role );
     }
 
+    /**
+     * @since 3.2.0
+     */
+    public void executeMojo( MavenSession session, MavenProject project, MojoExecution execution )
+        throws Exception
+    {
+        SessionScope sessionScope = lookup( SessionScope.class );
+        try
+        {
+            sessionScope.enter();
+            sessionScope.seed( MavenSession.class, session );
+
+            MojoExecutionScope executionScope = lookup( MojoExecutionScope.class );
+            try
+            {
+                executionScope.enter();
+
+                executionScope.seed( MavenProject.class, project );
+                executionScope.seed( MojoExecution.class, execution );
+
+                Mojo mojo = lookupConfiguredMojo( session, execution );
+                mojo.execute();
+
+                MojoExecutionEvent event = new MojoExecutionEvent( session, project, execution, mojo );
+                for ( MojoExecutionListener listener : getContainer().lookupList( MojoExecutionListener.class ) )
+                {
+                    listener.afterMojoExecutionSuccess( event );
+                }
+            }
+            finally
+            {
+                executionScope.exit();
+            }
+        }
+        finally
+        {
+            sessionScope.exit();
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/maven-plugin-testing/blob/3c981e52/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 391e03c..a2ebed2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -145,7 +145,7 @@ under the License.
   </distributionManagement>
 
   <properties>
-    <mavenVersion>3.1.1</mavenVersion>
+    <mavenVersion>3.2.1</mavenVersion>
     <plexusVersion>1.5.5</plexusVersion>
     <maven.site.path>plugin-testing-archives/LATEST</maven.site.path>
     <!-- Not sure if this is intentional but MojoRule has an @Override annotation from the interface which is