maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r208719 - in /maven/scm/trunk/maven-scm-plugin: ./ src/main/java/org/apache/maven/scm/plugin/
Date Fri, 01 Jul 2005 06:20:31 GMT
Author: evenisse
Date: Thu Jun 30 23:20:28 2005
New Revision: 208719

URL: http://svn.apache.org/viewcvs?rev=208719&view=rev
Log:
Add more mojos.

Added:
    maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckinMojo.java
  (with props)
    maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/DiffMojo.java
  (with props)
    maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/StatusMojo.java
  (with props)
    maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/TagMojo.java
  (with props)
    maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UpdateMojo.java
  (with props)
Modified:
    maven/scm/trunk/maven-scm-plugin/pom.xml
    maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java
    maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java

Modified: maven/scm/trunk/maven-scm-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-plugin/pom.xml?rev=208719&r1=208718&r2=208719&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-plugin/pom.xml (original)
+++ maven/scm/trunk/maven-scm-plugin/pom.xml Thu Jun 30 23:20:28 2005
@@ -42,7 +42,7 @@
     </dependency>
     <dependency>
       <groupId>org.apache.maven.scm</groupId>
-      <artifactId>maven-scm-provider-cvs</artifactId>
+      <artifactId>maven-scm-provider-svn</artifactId>
       <version>1.0-alpha-2-SNAPSHOT</version>
     </dependency>
   </dependencies>

Modified: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java?rev=208719&r1=208718&r2=208719&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java
(original)
+++ maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java
Thu Jun 30 23:20:28 2005
@@ -17,9 +17,16 @@
  */
 
 import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
+import org.apache.maven.scm.repository.ScmRepository;
 import org.codehaus.plexus.scm.ScmManager;
 
 import java.io.File;
+import java.io.IOException;
 
 /**
  * @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
@@ -29,18 +36,66 @@
     extends AbstractMojo
 {
     /**
+     * The SCM connection URL.
+     * 
+     * @parameter expression="${connectionUrl}
+     * @required
+     */
+    private String connectionUrl;
+
+    /**
+     * The working directory
+     * 
      * @parameter expression="${basedir}"
      * @required
      */
     private File workingDirectory;
 
     /**
+     * The user name (used by svn protocol).
+     * 
+     * @parameter expression="${username}"
+     */
+    private String username;
+
+    /**
+     * The user password (used by svn protocol).
+     * 
+     * @parameter expression="${password}"
+     */
+    private String password;
+
+    /**
+     * The url of tags base directory (used by svn protocol).
+     * 
+     * @parameter expression="${tagBase}"
+     */
+    private String tagBase;
+
+    /**
+     * Comma separated list of includes file pattern.
+     * @parameter expression="${includes}" 
+     */
+    private String includes;
+
+    /**
+     * Comma separated list of excludes file pattern.
+     * @parameter expression="${excludes}" 
+     */
+    private String excludes;
+
+    /**
      * @parameter expression="${component.org.codehaus.plexus.scm.ScmManager}"
      * @required
      * @readonly
      */
     private ScmManager manager;
 
+    public String getConnectionUrl()
+    {
+        return connectionUrl;
+    }
+
     public File getWorkingDirectory()
     {
         return workingDirectory;
@@ -49,5 +104,72 @@
     public ScmManager getScmManager()
     {
         return manager;
+    }
+
+    public ScmFileSet getFileSet()
+        throws IOException
+    {
+        if ( includes != null || excludes != null )
+        {
+            return new ScmFileSet( getWorkingDirectory(), includes, excludes );
+        }
+        else
+        {
+            return new ScmFileSet( getWorkingDirectory() );
+        }
+    }
+
+    public ScmRepository getScmRepository()
+        throws ScmException
+    {
+        ScmRepository repository;
+
+        getScmManager().addListener( new DefaultLog( getLog() ) );
+
+        try
+        {
+            repository = getScmManager().makeScmRepository( getConnectionUrl() );
+
+            if ( repository.getProvider().equals( "svn" ) )
+            {
+                SvnScmProviderRepository svnRepo = (SvnScmProviderRepository) repository.getProviderRepository();
+
+                if ( username != null && username.length() > 0 )
+                {
+                    svnRepo.setUser( username );
+                }
+                if ( password != null && password.length() > 0 )
+                {
+                    svnRepo.setPassword( password );
+                }
+                if ( tagBase != null && tagBase.length() > 0 )
+                {
+                    svnRepo.setTagBase( tagBase );
+                }
+            }
+        }
+        catch ( Exception e )
+        {
+            throw new ScmException( "Can't load the scm provider.", e );
+        }
+
+        return repository;
+    }
+
+    public void checkResult( ScmResult result )
+        throws MojoExecutionException
+    {
+        if ( !result.isSuccess() )
+        {
+            getLog().error( "Provider message:" );
+
+            getLog().error( result.getProviderMessage() == null ? "" : result.getProviderMessage()
);
+
+            getLog().error( "Command output:" );
+
+            getLog().error( result.getCommandOutput() == null ? "" : result.getCommandOutput()
);
+
+            throw new MojoExecutionException( "Command failed." );
+        }
     }
 }

Added: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckinMojo.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckinMojo.java?rev=208719&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckinMojo.java
(added)
+++ maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckinMojo.java
Thu Jun 30 23:20:28 2005
@@ -0,0 +1,61 @@
+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.apache.maven.scm.ScmException;
+import org.apache.maven.scm.command.checkin.CheckInScmResult;
+import org.apache.maven.scm.repository.ScmRepository;
+
+import java.io.IOException;
+
+/**
+ * @goal checkin
+ * @description checkin the project
+ *
+ * @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class CheckinMojo
+    extends AbstractScmMojo
+{
+    /**
+     * @parameter expression="${message}
+     */
+    private String message;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        try
+        {
+            ScmRepository repository = getScmRepository();
+
+            CheckInScmResult result = getScmManager().checkIn( repository, getFileSet(),
null, message );
+
+            checkResult( result );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Cannot run checkout command : ", e );
+        }
+        catch ( ScmException e )
+        {
+            throw new MojoExecutionException( "Cannot run checkout command : ", e );
+        }
+    }
+}

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

Propchange: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckinMojo.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=208719&r1=208718&r2=208719&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
Thu Jun 30 23:20:28 2005
@@ -17,12 +17,11 @@
  */
 
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.scm.ScmFileSet;
-import org.apache.maven.scm.command.Command;
+import org.apache.maven.scm.ScmException;
 import org.apache.maven.scm.command.checkout.CheckOutScmResult;
 import org.apache.maven.scm.repository.ScmRepository;
 
-import java.io.File;
+import java.io.IOException;
 
 /**
  * @goal checkout
@@ -35,12 +34,6 @@
     extends AbstractScmMojo
 {
     /**
-     * @parameter expression="${connectionUrl}
-     * @required
-     */
-    private String connectionUrl;
-
-    /**
      * @parameter expression="${branch}
      */
     private String branch;
@@ -55,9 +48,7 @@
     {
         try
         {
-            getScmManager().addListener( new DefaultLog( getLog() ) );
-
-            ScmRepository repository = getScmManager().makeScmRepository( connectionUrl );
+            ScmRepository repository = getScmRepository();
 
             String currentTag = null;
 
@@ -71,17 +62,17 @@
                 currentTag = tag;
             }
 
-            CheckOutScmResult result = getScmManager().checkOut( repository, new ScmFileSet(
getWorkingDirectory() ), currentTag );
+            CheckOutScmResult result = getScmManager().checkOut( repository, getFileSet(),
currentTag );
 
-            if ( !result.isSuccess() )
-            {
-                getLog().error( result.getCommandOutput() );
-            }
+            checkResult( result );
         }
-        catch ( Exception e )
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Cannot run checkout command : ", e );
+        }
+        catch ( ScmException e )
         {
             throw new MojoExecutionException( "Cannot run checkout command : ", e );
         }
     }
 }
-

Added: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/DiffMojo.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/DiffMojo.java?rev=208719&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/DiffMojo.java
(added)
+++ maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/DiffMojo.java
Thu Jun 30 23:20:28 2005
@@ -0,0 +1,93 @@
+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.apache.maven.scm.ScmException;
+import org.apache.maven.scm.command.diff.DiffScmResult;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @goal diff
+ * @description Create a diff
+ *
+ * @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class DiffMojo
+    extends AbstractScmMojo
+{
+    /**
+     * Start revision id
+     *
+     * @parameter expression="${startRevision}
+     */
+    private String startRevision;
+
+    /**
+     * End revision id
+     *
+     * @parameter expression="${endRevision}
+     */
+    private String endRevision;
+
+    /**
+     * Output file name
+     *
+     * @parameter expression="${outputFile}
+     */
+    private File outputFile;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        try
+        {
+            ScmRepository repository = getScmRepository();
+
+            DiffScmResult result = getScmManager().diff( repository, getFileSet(), startRevision,
endRevision );
+
+            checkResult( result );
+
+            getLog().info( result.getPatch() );
+
+            try
+            {
+                if ( outputFile != null )
+                {
+                    FileUtils.fileWrite( outputFile.getAbsolutePath(), result.getPatch()
);
+                }
+            }
+            catch ( IOException e )
+            {
+                throw new MojoExecutionException( "Can't write patch file.", e );
+            }
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Cannot run checkout command : ", e );
+        }
+        catch ( ScmException e )
+        {
+            throw new MojoExecutionException( "Cannot run diff command : ", e );
+        }
+    }
+}

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

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

Added: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/StatusMojo.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/StatusMojo.java?rev=208719&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/StatusMojo.java
(added)
+++ maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/StatusMojo.java
Thu Jun 30 23:20:28 2005
@@ -0,0 +1,58 @@
+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.apache.maven.scm.ScmException;
+import org.apache.maven.scm.command.status.StatusScmResult;
+import org.apache.maven.scm.repository.ScmRepository;
+
+import java.io.IOException;
+
+/**
+ * @goal status
+ * @description Project status
+ *
+ * @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class StatusMojo
+    extends AbstractScmMojo
+{
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        try
+        {
+            ScmRepository repository = getScmRepository();
+
+            StatusScmResult result = getScmManager().status( repository, getFileSet() );
+
+            checkResult( result );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Cannot run checkout command : ", e );
+        }
+        catch ( ScmException e )
+        {
+            throw new MojoExecutionException( "Cannot run checkout command : ", e );
+        }
+    }
+
+}

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

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

Added: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/TagMojo.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/TagMojo.java?rev=208719&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/TagMojo.java
(added)
+++ maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/TagMojo.java
Thu Jun 30 23:20:28 2005
@@ -0,0 +1,62 @@
+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.apache.maven.scm.ScmException;
+import org.apache.maven.scm.command.tag.TagScmResult;
+import org.apache.maven.scm.repository.ScmRepository;
+
+import java.io.IOException;
+
+/**
+ * @goal tag
+ * @description Tag the project
+ *
+ * @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class TagMojo
+    extends AbstractScmMojo
+{
+    /**
+     * @parameter expression="${tag}
+     */
+    private String tag;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        try
+        {
+            ScmRepository repository = getScmRepository();
+
+            TagScmResult result = getScmManager().tag( repository, getFileSet(), tag );
+
+            checkResult( result );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Cannot run checkout command : ", e );
+        }
+        catch ( ScmException e )
+        {
+            throw new MojoExecutionException( "Cannot run checkout command : ", e );
+        }
+    }
+
+}

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

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

Added: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UpdateMojo.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UpdateMojo.java?rev=208719&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UpdateMojo.java
(added)
+++ maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/UpdateMojo.java
Thu Jun 30 23:20:28 2005
@@ -0,0 +1,78 @@
+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.apache.maven.scm.ScmException;
+import org.apache.maven.scm.command.update.UpdateScmResult;
+import org.apache.maven.scm.repository.ScmRepository;
+
+import java.io.IOException;
+
+/**
+ * @goal update
+ * @description Update the project
+ *
+ * @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class UpdateMojo
+    extends AbstractScmMojo
+{
+    /**
+     * @parameter expression="${branch}
+     */
+    private String branch;
+
+    /**
+     * @parameter expression="${tag}
+     */
+    private String tag;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        try
+        {
+            ScmRepository repository = getScmRepository();
+
+            String currentTag = null;
+
+            if ( branch != null )
+            {
+                currentTag = branch;
+            }
+
+            if ( tag != null )
+            {
+                currentTag = tag;
+            }
+
+            UpdateScmResult result = getScmManager().update( repository, getFileSet(), currentTag
);
+
+            checkResult( result );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Cannot run checkout command : ", e );
+        }
+        catch ( ScmException e )
+        {
+            throw new MojoExecutionException( "Cannot run checkout command : ", e );
+        }
+    }
+}

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

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



Mime
View raw message