Author: dantran
Date: Sun Jan 11 02:17:52 2009
New Revision: 733442

URL: http://svn.apache.org/viewvc?rev=733442&view=rev
Log:
SCM-438: support skipExportIfExists similar to checkout's skipCheckoutIfExists

Added:
    
maven/scm/trunk/maven-scm-plugin/src/test/resources/mojos/export/exportWhenExportDirectoryExistsAndSkip.xml
Modified:
    
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/ExportMojoTest.java

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=733442&r1=733441&r2=733442&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
 Sun Jan 11 02:17:52 2009
@@ -57,6 +57,14 @@
      * @required
      */
     private File exportDirectory;
+    
+    /**
+     * Skip export if exportDirectory exists.
+     *
+     * @parameter expression="${skipExportIfExists}" default-value="false"
+     */
+    private boolean skipExportIfExists = false;
+    
 
     /** {...@inheritdoc} */
     public void execute()
@@ -80,6 +88,11 @@
     {
         super.execute();
 
+        if ( this.skipExportIfExists && this.exportDirectory.isDirectory()  )
+        {
+            return;
+        }
+        
         try
         {
             ScmRepository repository = getScmRepository();

Modified: 
maven/scm/trunk/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ExportMojoTest.java
URL: 
http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ExportMojoTest.java?rev=733442&r1=733441&r2=733442&view=diff
==============================================================================
--- 
maven/scm/trunk/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ExportMojoTest.java
 (original)
+++ 
maven/scm/trunk/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ExportMojoTest.java
 Sun Jan 11 02:17:52 2009
@@ -44,7 +44,6 @@
     }
 
     public void testExport()
-
         throws Exception
     {
         SvnScmTestUtils.initializeRepository( repository );
@@ -58,5 +57,20 @@
         assertTrue( exportDir.listFiles().length > 0  );
         assertFalse( new File( exportDir, ".svn" ).exists() );
     }
+    
+    public void testSkipExportIfExists()
+        throws Exception
+    {
+        exportDir.mkdirs();
+
+        ExportMojo mojo = (ExportMojo) lookupMojo( "export", getTestFile(
+            
"src/test/resources/mojos/export/exportWhenExportDirectoryExistsAndSkip.xml" ) 
);
+
+        mojo.setExportDirectory( exportDir );
+
+        mojo.execute();
+
+        assertEquals( 0, exportDir.listFiles().length );        
+    }
 
 }

Added: 
maven/scm/trunk/maven-scm-plugin/src/test/resources/mojos/export/exportWhenExportDirectoryExistsAndSkip.xml
URL: 
http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-plugin/src/test/resources/mojos/export/exportWhenExportDirectoryExistsAndSkip.xml?rev=733442&view=auto
==============================================================================
--- 
maven/scm/trunk/maven-scm-plugin/src/test/resources/mojos/export/exportWhenExportDirectoryExistsAndSkip.xml
 (added)
+++ 
maven/scm/trunk/maven-scm-plugin/src/test/resources/mojos/export/exportWhenExportDirectoryExistsAndSkip.xml
 Sun Jan 11 02:17:52 2009
@@ -0,0 +1,33 @@
+<!--
+  ~ 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>
+          <exportDirectory>target/export</exportDirectory>
+          
<connectionUrl>scm:svn:http://svn.apache.org/repos/asf/maven/scm/trunk</connectionUrl>
+          <skipExportIfExists>true</skipExportIfExists>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file


Reply via email to