Author: vsiveton
Date: Tue Nov 13 14:58:24 2007
New Revision: 594692

URL: http://svn.apache.org/viewvc?rev=594692&view=rev
Log:
MCLEAN-22: Possibility to ignore deletion failures

o added ignoreErrors parameter
o added documentation

Added:
    
maven/plugins/trunk/maven-clean-plugin/src/site/apt/examples/ignoring-errors.apt
   (with props)
Modified:
    
maven/plugins/trunk/maven-clean-plugin/src/main/java/org/apache/maven/plugin/clean/CleanMojo.java
    maven/plugins/trunk/maven-clean-plugin/src/site/site.xml

Modified: 
maven/plugins/trunk/maven-clean-plugin/src/main/java/org/apache/maven/plugin/clean/CleanMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-clean-plugin/src/main/java/org/apache/maven/plugin/clean/CleanMojo.java?rev=594692&r1=594691&r2=594692&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-clean-plugin/src/main/java/org/apache/maven/plugin/clean/CleanMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-clean-plugin/src/main/java/org/apache/maven/plugin/clean/CleanMojo.java
 Tue Nov 13 14:58:24 2007
@@ -130,6 +130,14 @@
     private boolean skip;
 
     /**
+     * Disable the plugin execution.
+     *
+     * @parameter expression="${clean.ignore.errors}" default-value="false"
+     * @since 2.2
+     */
+    private boolean ignoreErrors;
+
+    /**
      * Deletes file-sets in the following project build directory order:
      * (source) directory, output directory, test directory, report directory,
      * and then the additional file-sets.
@@ -146,14 +154,26 @@
             return;
         }
 
-        fileSetManager = new FileSetManager( getLog(), verbose );
+        try
+        {
+            fileSetManager = new FileSetManager( getLog(), verbose );
+
+            removeDirectory( directory );
+            removeDirectory( outputDirectory );
+            removeDirectory( testOutputDirectory );
+            removeDirectory( reportDirectory );
 
-        removeDirectory( directory );
-        removeDirectory( outputDirectory );
-        removeDirectory( testOutputDirectory );
-        removeDirectory( reportDirectory );
+            removeAdditionalFilesets();
+        }
+        catch ( MojoExecutionException e )
+        {
+            if ( !ignoreErrors )
+            {
+                throw e;
+            }
 
-        removeAdditionalFilesets();
+            getLog().warn( e.getMessage() );
+        }
     }
 
     /**

Added: 
maven/plugins/trunk/maven-clean-plugin/src/site/apt/examples/ignoring-errors.apt
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-clean-plugin/src/site/apt/examples/ignoring-errors.apt?rev=594692&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-clean-plugin/src/site/apt/examples/ignoring-errors.apt
 (added)
+++ 
maven/plugins/trunk/maven-clean-plugin/src/site/apt/examples/ignoring-errors.apt
 Tue Nov 13 14:58:24 2007
@@ -0,0 +1,50 @@
+ ------
+ Ignoring Clean Errors
+ ------
+ Vincent Siveton
+ ------
+ 13 November 2007
+ ------
+
+~~ 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.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/guides/mini/guide-apt-format.html
+
+Ignoring Clean Errors
+
+  To ignore errors when running the cleanup for a particular project, set the 
ignoreErrors property to true.
+
++--------
+<build>
+  [...]
+    <plugin>
+      <artifactId>maven-clean-plugin</artifactId>
+      <configuration>
+        <ignoreErrors>true</ignoreErrors>
+      </configuration>
+    </plugin>
+  [...]
+</build>
++---------
+
+  You can also ignore them via command line by executing the following command:
+
++--------
+mvn clean -Dclean.ignore.errors=true
++---------

Propchange: 
maven/plugins/trunk/maven-clean-plugin/src/site/apt/examples/ignoring-errors.apt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-clean-plugin/src/site/apt/examples/ignoring-errors.apt
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/plugins/trunk/maven-clean-plugin/src/site/site.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-clean-plugin/src/site/site.xml?rev=594692&r1=594691&r2=594692&view=diff
==============================================================================
--- maven/plugins/trunk/maven-clean-plugin/src/site/site.xml (original)
+++ maven/plugins/trunk/maven-clean-plugin/src/site/site.xml Tue Nov 13 
14:58:24 2007
@@ -29,6 +29,7 @@
     </menu>
     <menu name="Examples">
       <item name="Skipping Clean" href="examples/skipping-clean.html"/>
+      <item name="Ignoring Errors" href="examples/ignoring-errors.html"/>
       <item name="Delete Additional Files" 
href="examples/delete_additional_files.html"/>
     </menu>
   </body>


Reply via email to