maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dant...@apache.org
Subject svn commit: r928126 - in /maven/scm/trunk/maven-scm-plugin: ./ src/main/java/org/apache/maven/scm/plugin/ src/test/java/org/apache/maven/scm/plugin/ src/test/resources/mojos/checkout/
Date Sat, 27 Mar 2010 02:46:49 GMT
Author: dantran
Date: Sat Mar 27 02:46:49 2010
New Revision: 928126

URL: http://svn.apache.org/viewvc?rev=928126&view=rev
Log:
[SCM-526] initial implementation to be activated after tests are tested at unix box

Added:
    maven/scm/trunk/maven-scm-plugin/src/test/resources/mojos/checkout/checkoutWithExcludesIncludes.xml
  (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
    maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ExportMojo.java
    maven/scm/trunk/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/CheckoutMojoTest.java

Modified: maven/scm/trunk/maven-scm-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-plugin/pom.xml?rev=928126&r1=928125&r2=928126&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-plugin/pom.xml (original)
+++ maven/scm/trunk/maven-scm-plugin/pom.xml Sat Mar 27 02:46:49 2010
@@ -105,6 +105,13 @@
       <artifactId>plexus-utils</artifactId>
       <version>1.5.6</version>
     </dependency>
+    
+    <dependency>
+      <groupId>org.apache.maven.shared</groupId>
+      <artifactId>file-management</artifactId>
+      <version>1.2.1</version>
+    </dependency>
+    
 
     <!-- Test -->
     <dependency>

Modified: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java?rev=928126&r1=928125&r2=928126&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
Sat Mar 27 02:46:49 2010
@@ -36,11 +36,15 @@ import org.apache.maven.scm.repository.S
 import org.apache.maven.scm.repository.ScmRepositoryException;
 import org.apache.maven.settings.Server;
 import org.apache.maven.settings.Settings;
+import org.apache.maven.shared.model.fileset.FileSet;
+import org.apache.maven.shared.model.fileset.util.FileSetManager;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
@@ -463,4 +467,53 @@ public abstract class AbstractScmMojo
 
         throw new MojoExecutionException( "Unknown '" + versionType + "' version type." );
     }
+    
+    protected void cleanCheckoutDirectory( File checkoutDirectory )
+        throws MojoExecutionException
+    {
+        List includes = new ArrayList();
+
+        if ( ! StringUtils.isBlank( this.getIncludes() ) )
+        {
+            String[] tokens = StringUtils.split( this.getIncludes(), "," );
+            for ( int i = 0; i < tokens.length; ++i )
+            {
+                includes.add( tokens[i] );
+            }
+        }
+
+        List excludes = new ArrayList();
+
+        if ( ! StringUtils.isBlank( this.getExcludes() ) )
+        {
+            String[] tokens = StringUtils.split( this.getExcludes(), "," );
+            for ( int i = 0; i < tokens.length; ++i )
+            {
+                excludes.add( tokens[i] );
+            }
+        }
+        
+        if ( includes.isEmpty() &&  excludes.isEmpty() )
+        {
+            return;
+        }
+
+        FileSetManager fileSetManager = new FileSetManager();
+
+        FileSet fileset = new FileSet();
+        fileset.setDirectory( checkoutDirectory.getAbsolutePath() );
+        fileset.setIncludes( includes );
+        fileset.setExcludes( excludes );
+        fileset.setUseDefaultExcludes( false );
+
+        try
+        {
+            fileSetManager.delete( fileset );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Error found while cleaning up output directory
base on excludes/includes configurations.", e );
+        }
+
+    }
 }

Modified: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java?rev=928126&r1=928125&r2=928126&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
Sat Mar 27 02:46:49 2010
@@ -126,6 +126,9 @@ public class CheckoutMojo
             }
 
             checkResult( result );
+            
+            //to be activated after tests are fully added
+            //cleanCheckoutDirectory( this.checkoutDirectory );
 
             return result;
         }
@@ -159,4 +162,6 @@ public class CheckoutMojo
     {
         return checkoutResult;
     }
+    
+
 }

Modified: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ExportMojo.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ExportMojo.java?rev=928126&r1=928125&r2=928126&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ExportMojo.java
(original)
+++ maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ExportMojo.java
Sat Mar 27 02:46:49 2010
@@ -121,6 +121,9 @@ public class ExportMojo
                                                              getScmVersion( scmVersionType,
scmVersion ) );
 
             checkResult( result );
+            
+            //to be activated after tests are fully added
+            //cleanCheckoutDirectory( this.exportDirectory );            
         }
         catch ( ScmException e )
         {

Modified: maven/scm/trunk/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/CheckoutMojoTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/CheckoutMojoTest.java?rev=928126&r1=928125&r2=928126&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/CheckoutMojoTest.java
(original)
+++ maven/scm/trunk/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/CheckoutMojoTest.java
Sat Mar 27 02:46:49 2010
@@ -123,5 +123,25 @@ public class CheckoutMojoTest
         mojo.execute();
 
         assertTrue( checkoutDir.listFiles().length > 0  );
-        assertFalse( new File( checkoutDir, ".svn" ).exists() );    }    
+        assertFalse( new File( checkoutDir, ".svn" ).exists() );    
+    }
+    
+    public void notestExcludeInclude()
+        throws Exception
+    {
+        checkoutDir.mkdirs();
+
+        CheckoutMojo mojo = (CheckoutMojo) lookupMojo(
+                                                       "checkout",
+                                                       getTestFile( "src/test/resources/mojos/checkout/checkoutWithExcludesIncludes.xml"
) );
+
+        mojo.setCheckoutDirectory( checkoutDir );
+
+        mojo.execute();
+
+        assertTrue( checkoutDir.listFiles().length > 0 );
+        assertFalse( new File( checkoutDir, "pom.xml" ).exists() );
+        //assertFalse( ! new File( checkoutDir, "readme.txt" ).exists() );
+    }
+    
 }

Added: maven/scm/trunk/maven-scm-plugin/src/test/resources/mojos/checkout/checkoutWithExcludesIncludes.xml
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-plugin/src/test/resources/mojos/checkout/checkoutWithExcludesIncludes.xml?rev=928126&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-plugin/src/test/resources/mojos/checkout/checkoutWithExcludesIncludes.xml
(added)
+++ maven/scm/trunk/maven-scm-plugin/src/test/resources/mojos/checkout/checkoutWithExcludesIncludes.xml
Sat Mar 27 02:46:49 2010
@@ -0,0 +1,36 @@
+<!--
+  ~ 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.
+  -->
+
+<project>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-scm-plugin</artifactId>
+        <configuration>
+          <settings implementation="org.apache.maven.settings.Settings"/>
+          <checkoutDirectory>target/checkout</checkoutDirectory>
+          <connectionType>connection</connectionType>
+          <connectionUrl>scm:svn:file:///${basedir}/target/repository/trunk</connectionUrl>
+          <includes>pom.xml</includes>
+          <excludes>readme.txt,src/test</excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file

Propchange: maven/scm/trunk/maven-scm-plugin/src/test/resources/mojos/checkout/checkoutWithExcludesIncludes.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message