You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kr...@apache.org on 2012/08/06 20:46:59 UTC

svn commit: r1369919 - /maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java

Author: krosenvold
Date: Mon Aug  6 18:46:59 2012
New Revision: 1369919

URL: http://svn.apache.org/viewvc?rev=1369919&view=rev
Log:
[SUREFIRE-846] Do not leave target/surefire folder around unless debug logging is on

Patch by Martin Todorov, applied with some changes

Modified:
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java?rev=1369919&r1=1369918&r2=1369919&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java Mon Aug  6 18:46:59 2012
@@ -81,6 +81,7 @@ import org.apache.maven.surefire.util.Ru
 import org.apache.maven.surefire.util.ScanResult;
 import org.apache.maven.toolchain.Toolchain;
 import org.apache.maven.toolchain.ToolchainManager;
+import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.StringUtils;
 
 /**
@@ -703,6 +704,26 @@ public abstract class AbstractSurefireMo
         {
             summary.registerException( e );
         }
+        finally
+        {
+            cleanupForkConfiguration( forkConfiguration );
+        }
+    }
+
+    protected void cleanupForkConfiguration( ForkConfiguration forkConfiguration )
+    {
+        if ( !getLog().isDebugEnabled() && forkConfiguration != null )
+        {
+            File tempDirectory = forkConfiguration.getTempDirectory();
+            try
+            {
+                FileUtils.deleteDirectory( tempDirectory );
+            }
+            catch ( IOException ioe )
+            {
+                getLog().warn( "Could not delete temp direcotry " + tempDirectory + " because " + ioe.getMessage() );
+            }
+        }
     }
 
     protected abstract void handleSummary( Summary summary )