You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by df...@apache.org on 2008/09/23 22:06:33 UTC

svn commit: r698326 - in /maven/plugins/trunk/maven-reactor-plugin/src: main/java/org/apache/maven/plugin/reactor/ site/apt/ test/java/org/apache/maven/plugin/reactor/

Author: dfabulich
Date: Tue Sep 23 13:06:32 2008
New Revision: 698326

URL: http://svn.apache.org/viewvc?rev=698326&view=rev
Log:
[MREACTOR-5] Allow resuming a "make" build

Modified:
    maven/plugins/trunk/maven-reactor-plugin/src/main/java/org/apache/maven/plugin/reactor/MakeMojo.java
    maven/plugins/trunk/maven-reactor-plugin/src/main/java/org/apache/maven/plugin/reactor/ResumeMojo.java
    maven/plugins/trunk/maven-reactor-plugin/src/site/apt/examples.apt.vm
    maven/plugins/trunk/maven-reactor-plugin/src/test/java/org/apache/maven/plugin/reactor/MakeMojoTest.java

Modified: maven/plugins/trunk/maven-reactor-plugin/src/main/java/org/apache/maven/plugin/reactor/MakeMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-reactor-plugin/src/main/java/org/apache/maven/plugin/reactor/MakeMojo.java?rev=698326&r1=698325&r2=698326&view=diff
==============================================================================
--- maven/plugins/trunk/maven-reactor-plugin/src/main/java/org/apache/maven/plugin/reactor/MakeMojo.java (original)
+++ maven/plugins/trunk/maven-reactor-plugin/src/main/java/org/apache/maven/plugin/reactor/MakeMojo.java Tue Sep 23 13:06:32 2008
@@ -104,6 +104,18 @@
      */
     SimpleInvoker simpleInvoker;
     
+    /**
+     * The artifact from which we'll resume, e.g. "com.mycompany:foo" or just "foo"
+     * @parameter expression="${fromArtifact}"
+     */
+    String continueFromProject;
+    
+    /**
+     * The project folder from which we'll resume
+     * @parameter expression="${from}"
+     */
+    File continueFromFolder;
+    
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
@@ -111,6 +123,7 @@
             throw new MojoFailureException("You must specify either folders or projects with -Dmake.folders=foo,baz/bar or -Dmake.projects=com.mycompany:foo,com.mycompany:bar");
         }
         String[] reactorIncludes;
+        List sortedProjects;
         try
         {
             if (collectedProjects.size() == 0) {
@@ -136,7 +149,7 @@
             
             // sort them again
             ps = new SuperProjectSorter( new ArrayList( out ) );
-            List sortedProjects = ps.getSortedProjects();
+            sortedProjects = ps.getSortedProjects();
             
             // construct array of relative POM paths
             reactorIncludes = new String[sortedProjects.size()];
@@ -155,7 +168,21 @@
             throw new MojoExecutionException( "Problem generating dependency tree", e );
         }
 
-        simpleInvoker.runReactor( reactorIncludes, Arrays.asList( goals.split( "," ) ), invoker, printOnly, getLog() );
+        if (continueFromFolder != null || continueFromProject != null) {
+            ResumeMojo resumer = new ResumeMojo();
+            resumer.baseDir = baseDir;
+            resumer.collectedProjects = sortedProjects;
+            resumer.continueFromFolder = continueFromFolder;
+            resumer.continueFromProject = continueFromProject;
+            resumer.goals = goals;
+            resumer.invoker = invoker;
+            resumer.simpleInvoker = simpleInvoker;
+            resumer.printOnly = printOnly;
+            resumer.continueFromGroup = defaultGroup;
+            resumer.execute();
+        } else {
+            simpleInvoker.runReactor( reactorIncludes, Arrays.asList( goals.split( "," ) ), invoker, printOnly, getLog() );
+        }
 
     }
 

Modified: maven/plugins/trunk/maven-reactor-plugin/src/main/java/org/apache/maven/plugin/reactor/ResumeMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-reactor-plugin/src/main/java/org/apache/maven/plugin/reactor/ResumeMojo.java?rev=698326&r1=698325&r2=698326&view=diff
==============================================================================
--- maven/plugins/trunk/maven-reactor-plugin/src/main/java/org/apache/maven/plugin/reactor/ResumeMojo.java (original)
+++ maven/plugins/trunk/maven-reactor-plugin/src/main/java/org/apache/maven/plugin/reactor/ResumeMojo.java Tue Sep 23 13:06:32 2008
@@ -45,49 +45,54 @@
     /**
      * @parameter expression="${project.collectedProjects}"
      */
-    private List collectedProjects;
+    List collectedProjects;
     
     /**
      * Location of the file.
      * @parameter expression="${basedir}"
      */
-    private File baseDir;
+    File baseDir;
     
     /**
      * @parameter expression="${make.group}" default-value="${project.groupId}"
      */
-    private String continueFromGroup;
+    String continueFromGroup;
     
     /**
      * The artifact from which we'll resume, e.g. "com.mycompany:foo" or just "foo"
      * @parameter expression="${fromArtifact}" default-value="null"
      * @required
      */
-    private String continueFromProject;
+    String continueFromProject;
     
     /**
      * The project folder from which we'll resume
      * @parameter expression="${from}" default-value="null"
      * @required
      */
-    private File continueFromFolder;
+    File continueFromFolder;
     
     /**
      * Goals to run on subproject
      * @parameter expression="${make.goals}" default-value="install"
      */
-    private String goals;
+    String goals;
     
     /**
      * @component
      */
-    private Invoker invoker;
+    Invoker invoker;
     
     /**
      * Don't really do anything; just print a message that describes what the command would have done
      * @parameter expression="${make.printOnly}"
      */
-    private boolean printOnly = false;
+    boolean printOnly = false;
+    
+    /**
+     * @component
+     */
+    SimpleInvoker simpleInvoker;
     
     public void execute()
         throws MojoExecutionException, MojoFailureException
@@ -173,7 +178,7 @@
             throw new MojoExecutionException( "Problem generating dependency tree", e );
         }
 
-        new SimpleInvoker().runReactor( reactorIncludes, Arrays.asList( goals.split( "," ) ), invoker, printOnly, getLog() );
+        simpleInvoker.runReactor( reactorIncludes, Arrays.asList( goals.split( "," ) ), invoker, printOnly, getLog() );
 
     }
 }

Modified: maven/plugins/trunk/maven-reactor-plugin/src/site/apt/examples.apt.vm
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-reactor-plugin/src/site/apt/examples.apt.vm?rev=698326&r1=698325&r2=698326&view=diff
==============================================================================
--- maven/plugins/trunk/maven-reactor-plugin/src/site/apt/examples.apt.vm (original)
+++ maven/plugins/trunk/maven-reactor-plugin/src/site/apt/examples.apt.vm Tue Sep 23 13:06:32 2008
@@ -153,6 +153,16 @@
   
   If you want to get really fancy, you may prefer to just dry run the reactor plugin in <<<-Dmake.printOnly>>> mode, described above.  That will print out the command that the plugin would have used to build, but you can tweak that command line to your heart's content!
 
+* Resuming a "make" build
+
+  When you use <<<reactor:make>>>, you run a subset of projects, but that doesn't mean stuff won't fail halfway through the build.  You can resume a <<<reactor:make>>> build from the project that stopped the build by passing <<<-Dfrom>>> to the <<<reactor:make>>> goal, like this:
+
++---+
+mvn reactor:make -Dmake.folders=fooUI -Dfrom=barBusinessLogic
++---+
+
+  The <<<-Dfrom>>> argument also works with <<<reactor:make-dependents>>> and <<<reactor:make-scm-changes>>>.
+
 * Nested directories
 
   Let's consider a more complex project:
@@ -220,3 +230,4 @@
 +---+
 mvn reactor:make -Dmake.artifacts=quzUI
 +---+
+

Modified: maven/plugins/trunk/maven-reactor-plugin/src/test/java/org/apache/maven/plugin/reactor/MakeMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-reactor-plugin/src/test/java/org/apache/maven/plugin/reactor/MakeMojoTest.java?rev=698326&r1=698325&r2=698326&view=diff
==============================================================================
--- maven/plugins/trunk/maven-reactor-plugin/src/test/java/org/apache/maven/plugin/reactor/MakeMojoTest.java (original)
+++ maven/plugins/trunk/maven-reactor-plugin/src/test/java/org/apache/maven/plugin/reactor/MakeMojoTest.java Tue Sep 23 13:06:32 2008
@@ -114,6 +114,19 @@
         assertEquals("businessLogic/pom.xml,ui/pom.xml", fi.getIncludes());
     }
     
+    public void testMakeResume() throws Exception {
+        MakeMojo m = new MakeMojo();
+        m.collectedProjects = configuredProjects;
+        m.artifactList = "reactortest:ui";
+        m.continueFromFolder = new File(baseDir, "businessLogic");
+        m.baseDir = baseDir;
+        m.goals = "install";
+        FakeInvoker fi = new FakeInvoker();
+        m.simpleInvoker = fi;
+        m.execute();
+        assertEquals("businessLogic/pom.xml,ui/pom.xml", fi.getIncludes());
+    }
+    
     class FakeInvoker extends SimpleInvoker {
         String[] reactorIncludes;
         List goalList;