Author: bentmann
Date: Wed Aug 26 11:56:59 2009
New Revision: 807971

URL: http://svn.apache.org/viewvc?rev=807971&view=rev
Log:
o Extended IT plugin to allow testing of forking+aggregation

Added:
    
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkGoalAggregatorMojo.java
   (with props)
    
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkGoalMojo.java
      - copied, changed from r803014, 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/CoreItGoalForkerMojo.java
    
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleAggregatorMojo.java
   (with props)
    
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleMojo.java
      - copied, changed from r803014, 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/CoreItForkerMojo.java
    
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/TouchMojo.java
      - copied, changed from r803014, 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
Removed:
    
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/CoreItForkerMojo.java
    
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/CoreItGoalForkerMojo.java
    
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java

Added: 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkGoalAggregatorMojo.java
URL: 
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkGoalAggregatorMojo.java?rev=807971&view=auto
==============================================================================
--- 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkGoalAggregatorMojo.java
 (added)
+++ 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkGoalAggregatorMojo.java
 Wed Aug 26 11:56:59 2009
@@ -0,0 +1,69 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * @goal fork-goal-aggregator
+ * @aggregator true
+ *
+ * @execute goal="touch"
+ */
+public class ForkGoalAggregatorMojo
+    extends AbstractMojo
+{
+    /**
+     * @parameter expression="${project}"
+     */
+    private MavenProject project;
+
+    /**
+     * @parameter expression="${reactorProjects}"
+     */
+    private List reactorProjects;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
+        {
+            MavenProject executedProject = ( (MavenProject) it.next() 
).getExecutionProject();
+
+            if ( !executedProject.getBuild().getFinalName().equals( 
TouchMojo.FINAL_NAME ) )
+            {
+                throw new MojoExecutionException( "Unexpected result, final 
name of executed project "
+                    + executedProject + " is " + 
executedProject.getBuild().getFinalName() + " (should be \'"
+                    + TouchMojo.FINAL_NAME + "\')." );
+            }
+        }
+
+        if ( project.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) )
+        {
+            throw new MojoExecutionException( "forked project was polluted. 
(should NOT be \'" + TouchMojo.FINAL_NAME
+                + "\')." );
+        }
+    }
+}

Propchange: 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkGoalAggregatorMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkGoalAggregatorMojo.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkGoalMojo.java
 (from r803014, 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/CoreItGoalForkerMojo.java)
URL: 
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkGoalMojo.java?p2=maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkGoalMojo.java&p1=maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/CoreItGoalForkerMojo.java&r1=803014&r2=807971&rev=807971&view=diff
==============================================================================
--- 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/CoreItGoalForkerMojo.java
 (original)
+++ 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkGoalMojo.java
 Wed Aug 26 11:56:59 2009
@@ -28,7 +28,7 @@
  *
  * @execute goal="touch"
  */
-public class CoreItGoalForkerMojo
+public class ForkGoalMojo
     extends AbstractMojo
 {
     /**
@@ -44,14 +44,16 @@
     public void execute()
         throws MojoExecutionException
     {
-        if ( !executedProject.getBuild().getFinalName().equals( "coreitified" 
) )
+        if ( !executedProject.getBuild().getFinalName().equals( 
TouchMojo.FINAL_NAME ) )
         {
-            throw new MojoExecutionException( "Unexpected result, final name 
of executed project is " + executedProject.getBuild().getFinalName() + " 
(should be: \'coreitified\')." );
+            throw new MojoExecutionException( "Unexpected result, final name 
of executed project is "
+                + executedProject.getBuild().getFinalName() + " (should be \'" 
+ TouchMojo.FINAL_NAME + "\')." );
         }
 
-        if ( project.getBuild().getFinalName().equals( "coreitified" ) )
+        if ( project.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) )
         {
-            throw new MojoExecutionException( "forked project was polluted. 
(should NOT be: \'coreitified\')." );
+            throw new MojoExecutionException( "forked project was polluted. 
(should NOT be \'" + TouchMojo.FINAL_NAME
+                + "\')." );
         }
     }
 }

Added: 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleAggregatorMojo.java
URL: 
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleAggregatorMojo.java?rev=807971&view=auto
==============================================================================
--- 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleAggregatorMojo.java
 (added)
+++ 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleAggregatorMojo.java
 Wed Aug 26 11:56:59 2009
@@ -0,0 +1,71 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * @goal fork-lifecycle-aggregator
+ * @aggregator true
+ *
+ * @execute phase="generate-sources" lifecycle="foo"
+ */
+public class ForkLifecycleAggregatorMojo
+    extends AbstractMojo
+{
+
+    /**
+     * @parameter expression="${project}"
+     */
+    private MavenProject project;
+
+    /**
+     * @parameter expression="${reactorProjects}"
+     */
+    private List reactorProjects;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
+        {
+            MavenProject executedProject = ( (MavenProject) it.next() 
).getExecutionProject();
+
+            if ( !executedProject.getBuild().getFinalName().equals( 
TouchMojo.FINAL_NAME ) )
+            {
+                throw new MojoExecutionException( "Unexpected result, final 
name of executed project "
+                    + executedProject + " is " + 
executedProject.getBuild().getFinalName() + " (should be \'"
+                    + TouchMojo.FINAL_NAME + "\')." );
+            }
+        }
+
+        if ( project.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) )
+        {
+            throw new MojoExecutionException( "forked project was polluted. 
(should NOT be \'" + TouchMojo.FINAL_NAME
+                + "\')." );
+        }
+    }
+
+}

Propchange: 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleAggregatorMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleAggregatorMojo.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleMojo.java
 (from r803014, 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/CoreItForkerMojo.java)
URL: 
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleMojo.java?p2=maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleMojo.java&p1=maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/CoreItForkerMojo.java&r1=803014&r2=807971&rev=807971&view=diff
==============================================================================
--- 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/CoreItForkerMojo.java
 (original)
+++ 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkLifecycleMojo.java
 Wed Aug 26 11:56:59 2009
@@ -28,7 +28,7 @@
  *
  * @execute phase="generate-sources" lifecycle="foo"
  */
-public class CoreItForkerMojo
+public class ForkLifecycleMojo
     extends AbstractMojo
 {
     /**
@@ -44,14 +44,16 @@
     public void execute()
         throws MojoExecutionException
     {
-        if ( !executedProject.getBuild().getFinalName().equals( "coreitified" 
) )
+        if ( !executedProject.getBuild().getFinalName().equals( 
TouchMojo.FINAL_NAME ) )
         {
-            throw new MojoExecutionException( "Unexpected result, final name 
of executed project is " + executedProject.getBuild().getFinalName() + " 
(should be: \'coreitified\')." );
+            throw new MojoExecutionException( "Unexpected result, final name 
of executed project is "
+                + executedProject.getBuild().getFinalName() + " (should be \'" 
+ TouchMojo.FINAL_NAME + "\')." );
         }
 
-        if ( project.getBuild().getFinalName().equals( "coreitified" ) )
+        if ( project.getBuild().getFinalName().equals( TouchMojo.FINAL_NAME ) )
         {
-            throw new MojoExecutionException( "forked project was polluted. 
(should NOT be: \'coreitified\')." );
+            throw new MojoExecutionException( "forked project was polluted. 
(should NOT be \'" + TouchMojo.FINAL_NAME
+                + "\')." );
         }
     }
 }

Copied: 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/TouchMojo.java
 (from r803014, 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java)
URL: 
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/TouchMojo.java?p2=maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/TouchMojo.java&p1=maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java&r1=803014&r2=807971&rev=807971&view=diff
==============================================================================
--- 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
 (original)
+++ 
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/TouchMojo.java
 Wed Aug 26 11:56:59 2009
@@ -36,9 +36,12 @@
  *
  * @description Goal which cleans the build
  */
-public class CoreItMojo
+public class TouchMojo
     extends AbstractMojo
 {
+
+    static final String FINAL_NAME = "coreitified";
+
     /**
      * @parameter expression="${project}"
      */
@@ -48,7 +51,7 @@
      * @parameter expression="${project.build.directory}"
      * @required
      */
-    private String outputDirectory;
+    private File outputDirectory;
 
     /** Test setting of plugin-artifacts on the PluginDescriptor instance.
      * @parameter expression="${plugin.artifactMap}"
@@ -88,8 +91,12 @@
         {
             throw new MojoExecutionException( "Failing per \'fail\' parameter 
(specified in pom or system properties)" );
         }
-        
-        touch( new File( outputDirectory ), "touch.txt" );
+
+        getLog().info( "[MAVEN-CORE-IT-LOG] Project build directory " + 
project.getBuild().getDirectory() );
+
+        getLog().info( "[MAVEN-CORE-IT-LOG] Using output directory " + 
outputDirectory );
+
+        touch( outputDirectory, "touch.txt" );
 
         // This parameter should be aligned to the basedir as the parameter 
type is specified
         // as java.io.File
@@ -100,18 +107,16 @@
         }
         
         touch( basedirAlignmentDirectory, "touch.txt" );
-        
-        File outDir = new File( outputDirectory );
 
         // Test parameter setting
         if ( pluginItem != null )
         {
-            touch( outDir, pluginItem );
+            touch( outputDirectory, pluginItem );
         }
 
         if ( goalItem != null )
         {
-            touch( outDir, goalItem );
+            touch( outputDirectory, goalItem );
         }
         
         if ( artifactToFile != null )
@@ -122,10 +127,10 @@
             
             String filename = artifactFile.getAbsolutePath().replace('/', 
'_').replace(':', '_') + ".txt";
             
-            touch( outDir, filename );
+            touch( outputDirectory, filename );
         }
 
-        project.getBuild().setFinalName( "coreitified" );
+        project.getBuild().setFinalName( FINAL_NAME );
     }
 
     private static void touch( File dir, String file )


Reply via email to