You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2012/05/01 13:44:47 UTC

svn commit: r1332621 - in /maven/sandbox/trunk/plugins/maven-site-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish: AbstractScmPublishMojo.java ScmPublishInventoryMojo.java ScmPublishPublishMojo.java

Author: hboutemy
Date: Tue May  1 11:44:46 2012
New Revision: 1332621

URL: http://svn.apache.org/viewvc?rev=1332621&view=rev
Log:
factored out scm setup call in abstract base class

Modified:
    maven/sandbox/trunk/plugins/maven-site-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java
    maven/sandbox/trunk/plugins/maven-site-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishInventoryMojo.java
    maven/sandbox/trunk/plugins/maven-site-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishMojo.java

Modified: maven/sandbox/trunk/plugins/maven-site-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-site-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java?rev=1332621&r1=1332620&r2=1332621&view=diff
==============================================================================
--- maven/sandbox/trunk/plugins/maven-site-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java (original)
+++ maven/sandbox/trunk/plugins/maven-site-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java Tue May  1 11:44:46 2012
@@ -25,6 +25,8 @@ import java.util.Map;
 
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.scm.manager.NoSuchScmProviderException;
 import org.apache.maven.scm.manager.ScmManager;
@@ -32,9 +34,7 @@ import org.apache.maven.scm.provider.Scm
 import org.apache.maven.scm.repository.ScmRepository;
 import org.apache.maven.scm.repository.ScmRepositoryException;
 import org.apache.maven.settings.Settings;
-import org.apache.maven.shared.release.ReleaseExecutionException;
 import org.apache.maven.shared.release.config.ReleaseDescriptor;
-import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException;
 import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator;
 
 /**
@@ -189,7 +189,7 @@ public abstract class AbstractScmPublish
     }
 
     protected ReleaseDescriptor setupScm()
-        throws ReleaseScmRepositoryException, ReleaseExecutionException
+        throws ScmRepositoryException, NoSuchScmProviderException
     {
         String scmUrl;
         if ( localCheckout )
@@ -228,25 +228,33 @@ public abstract class AbstractScmPublish
             }
         }
 
+        scmRepository = scmRepositoryConfigurator.getConfiguredRepository( releaseDescriptor, settings );
+
+        scmProvider = scmRepositoryConfigurator.getRepositoryProvider( scmRepository );
+
+        return releaseDescriptor;
+    }
+
+    public void execute()
+        throws MojoExecutionException, MojoFailureException
+    {
+        // setup the scm plugin with help from release plugin utilities
         try
         {
-            scmRepository = scmRepositoryConfigurator.getConfiguredRepository( releaseDescriptor, settings );
-
-            scmProvider = scmRepositoryConfigurator.getRepositoryProvider( scmRepository );
+            setupScm();
         }
         catch ( ScmRepositoryException e )
         {
-            // TODO: rethink this error pattern.
-            logError( e.getMessage() );
-
-            throw new ReleaseScmRepositoryException( e.getMessage(), e.getValidationMessages() );
+            throw new MojoExecutionException( e.getMessage(), e );
         }
         catch ( NoSuchScmProviderException e )
         {
-            logError( e.getMessage() );
-
-            throw new ReleaseExecutionException( "Unable to configure SCM repository: " + e.getMessage(), e );
+            throw new MojoExecutionException( e.getMessage(), e );
         }
-        return releaseDescriptor;
+
+        scmPublishExecute();
     }
+
+    public abstract void scmPublishExecute()
+        throws MojoExecutionException, MojoFailureException;
 }
\ No newline at end of file

Modified: maven/sandbox/trunk/plugins/maven-site-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishInventoryMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-site-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishInventoryMojo.java?rev=1332621&r1=1332620&r2=1332621&view=diff
==============================================================================
--- maven/sandbox/trunk/plugins/maven-site-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishInventoryMojo.java (original)
+++ maven/sandbox/trunk/plugins/maven-site-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishInventoryMojo.java Tue May  1 11:44:46 2012
@@ -30,10 +30,6 @@ import org.apache.maven.project.MavenPro
 import org.apache.maven.scm.ScmException;
 import org.apache.maven.scm.ScmFileSet;
 import org.apache.maven.scm.command.checkout.CheckOutScmResult;
-import org.apache.maven.shared.release.ReleaseExecutionException;
-import org.apache.maven.shared.release.ReleaseFailureException;
-import org.apache.maven.shared.release.config.ReleaseDescriptor;
-import org.apache.maven.shared.release.scm.ReleaseScmCommandException;
 import org.apache.maven.shared.release.util.ReleaseUtil;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -62,13 +58,10 @@ public class ScmPublishInventoryMojo
     extends AbstractScmPublishMojo
 {
     private void checkoutExisting()
-        throws ReleaseExecutionException, ReleaseFailureException
+        throws MojoExecutionException
     {
-
         logInfo( "Checking out the pub tree ..." );
 
-        ReleaseDescriptor releaseDescriptor = setupScm();
-
         MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects );
         if ( checkoutDirectory.exists() )
         {
@@ -80,7 +73,7 @@ public class ScmPublishInventoryMojo
             {
                 logError( e.getMessage() );
 
-                throw new ReleaseExecutionException( "Unable to remove old checkout directory: " + e.getMessage(), e );
+                throw new MojoExecutionException( "Unable to remove old checkout directory: " + e.getMessage(), e );
             }
         }
 
@@ -97,13 +90,13 @@ public class ScmPublishInventoryMojo
         {
             logError( e.getMessage() );
 
-            throw new ReleaseExecutionException( "An error is occurred in the checkout process: " + e.getMessage(), e );
+            throw new MojoExecutionException( "An error is occurred in the checkout process: " + e.getMessage(), e );
         }
         catch ( IOException e )
         {
             logError( e.getMessage() );
 
-            throw new ReleaseExecutionException( "An error is occurred in the checkout process: " + e.getMessage(), e );
+            throw new MojoExecutionException( "An error is occurred in the checkout process: " + e.getMessage(), e );
         }
 
         String scmRelativePathProjectDirectory = scmResult.getRelativePathProjectDirectory();
@@ -116,7 +109,7 @@ public class ScmPublishInventoryMojo
             }
             catch ( IOException e )
             {
-                throw new ReleaseExecutionException( "Exception occurred while calculating common basedir: "
+                throw new MojoExecutionException( "Exception occurred while calculating common basedir: "
                     + e.getMessage(), e );
             }
 
@@ -130,7 +123,7 @@ public class ScmPublishInventoryMojo
             }
             catch ( IOException e )
             {
-                throw new ReleaseExecutionException( e.getMessage(), e );
+                throw new MojoExecutionException( e.getMessage(), e );
             }
             if ( rootProjectBasedir.length() > basedir.length() )
             {
@@ -138,14 +131,12 @@ public class ScmPublishInventoryMojo
             }
         }
 
-        // I don't seem to be using this. 
-        releaseDescriptor.setScmRelativePathProjectDirectory( scmRelativePathProjectDirectory );
-
         if ( !scmResult.isSuccess() )
         {
             logError( scmResult.getProviderMessage() );
 
-            throw new ReleaseScmCommandException( "Unable to checkout from SCM", scmResult );
+            throw new MojoExecutionException( "Unable to checkout from SCM" + "\nProvider message:\n"
+                + scmResult.getProviderMessage() + "\nCommand output:\n" + scmResult.getCommandOutput() );
         }
     }
 
@@ -165,26 +156,15 @@ public class ScmPublishInventoryMojo
         }
     }
 
-    public void execute()
+    public void scmPublishExecute()
         throws MojoExecutionException, MojoFailureException
     {
-        try
-        {
-            checkoutExisting();
+        checkoutExisting();
 
-            List<File> inventory = ScmPublishInventory.listInventoryFiles( checkoutDirectory );
+        List<File> inventory = ScmPublishInventory.listInventoryFiles( checkoutDirectory );
 
-            ScmPublishInventory.writeInventory( inventory, inventoryFile );
+        ScmPublishInventory.writeInventory( inventory, inventoryFile );
 
-            deleteInventory( inventory );
-        }
-        catch ( ReleaseExecutionException e )
-        {
-            throw new MojoExecutionException( e.getMessage(), e );
-        }
-        catch ( ReleaseFailureException e )
-        {
-            throw new MojoFailureException( e.getMessage(), e );
-        }
+        deleteInventory( inventory );
     }
 }

Modified: maven/sandbox/trunk/plugins/maven-site-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-site-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishMojo.java?rev=1332621&r1=1332620&r2=1332621&view=diff
==============================================================================
--- maven/sandbox/trunk/plugins/maven-site-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishMojo.java (original)
+++ maven/sandbox/trunk/plugins/maven-site-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishMojo.java Tue May  1 11:44:46 2012
@@ -44,8 +44,6 @@ import org.apache.maven.scm.ScmFileSet;
 import org.apache.maven.scm.command.add.AddScmResult;
 import org.apache.maven.scm.command.checkin.CheckInScmResult;
 import org.apache.maven.scm.command.remove.RemoveScmResult;
-import org.apache.maven.shared.release.ReleaseExecutionException;
-import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException;
 
 /**
  * Compare the list of files now on disk to the original inventory, then fire off scm adds and deletes as needed.
@@ -146,11 +144,7 @@ public class ScmPublishPublishMojo
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * @see org.apache.maven.plugin.Mojo#execute()
-     */
-    public void execute()
+    public void scmPublishExecute()
         throws MojoExecutionException, MojoFailureException
     {
         if ( siteOutputEncoding == null )
@@ -162,20 +156,6 @@ public class ScmPublishPublishMojo
         // read in the list left behind by prepare; fail if it's not there.
         List<File> inventory = ScmPublishInventory.readInventory( inventoryFile );
 
-        // setup the scm plugin with help from release plugin utilities
-        try
-        {
-            setupScm();
-        }
-        catch ( ReleaseScmRepositoryException e )
-        {
-            throw new MojoExecutionException( e.getMessage(), e );
-        }
-        catch ( ReleaseExecutionException e )
-        {
-            throw new MojoExecutionException( e.getMessage(), e );
-        }
-
         // what files are in stock now?
         Collection<File> newInventory = ScmPublishInventory.listInventoryFiles( checkoutDirectory );