You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm-commits@maven.apache.org by ev...@apache.org on 2005/11/08 22:23:48 UTC

svn commit: r331894 - in /maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin: BootstrapMojo.java CheckoutMojo.java

Author: evenisse
Date: Tue Nov  8 13:23:45 2005
New Revision: 331894

URL: http://svn.apache.org/viewcvs?rev=331894&view=rev
Log:
PR: SCM-63
Submitted by Dan Tran

Add scm:bootstrap mojo

Added:
    maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java   (with props)
Modified:
    maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java

Added: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java?rev=331894&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java (added)
+++ maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java Tue Nov  8 13:23:45 2005
@@ -0,0 +1,94 @@
+package org.apache.maven.scm.plugin;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.MojoExecutionException;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+import org.codehaus.plexus.util.cli.DefaultConsumer;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+
+/**
+ * @goal bootstrap
+ * @description Boostrap a project
+ *
+ * @author <a href="dantran@gmail.com">Dan T. Tran</a>
+ * @version $Id$
+ * @requiresProject false
+ */
+public class BootstrapMojo
+    extends CheckoutMojo
+{
+    
+    /**
+     * The goals to run on the clean checkout of a project for the bootstrap goal. 
+     * If none are specified, then the default goal for the project is executed. 
+     * Multiple goals should be comma separated. 
+     * @parameter expression="${goals}
+     */
+    
+    private String  goals;
+    
+    public void execute()
+        throws MojoExecutionException
+    {
+        checkout();
+        
+        runGoals();
+    }
+    
+    private void runGoals()
+        throws MojoExecutionException
+    {
+        Commandline cl = new Commandline();
+
+        cl.setExecutable( "mvn" );
+
+        cl.setWorkingDirectory(  this.getWorkingDirectory().getPath() );
+
+        if ( this.goals != null )
+        {
+            String [] tokens = StringUtils.split( this.goals, "," );
+            
+            for ( int i = 0 ; i < tokens.length ; ++i )
+            {
+                cl.createArgument().setValue( tokens[i] );
+            }
+        }
+
+        StreamConsumer consumer = new DefaultConsumer();
+
+        try
+        {
+            int result = CommandLineUtils.executeCommandLine( cl, consumer, consumer );
+
+            if ( result != 0 )
+            {
+                throw new MojoExecutionException( "Result of mvn execution is: \'" + result + "\'. Release failed." );
+            }
+        }
+        catch ( CommandLineException e )
+        {
+             throw new MojoExecutionException( "Can't run goal " + goals, e );
+        }
+    }
+    
+}

Propchange: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java?rev=331894&r1=331893&r2=331894&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java (original)
+++ maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java Tue Nov  8 13:23:45 2005
@@ -47,6 +47,12 @@
     public void execute()
         throws MojoExecutionException
     {
+        checkout();
+    }
+    
+    protected void checkout()
+       throws MojoExecutionException
+    {
         try
         {
             ScmRepository repository = getScmRepository();