You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ol...@apache.org on 2013/10/22 03:01:28 UTC

svn commit: r1534437 - /tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/RunMojo.java

Author: olamy
Date: Tue Oct 22 01:01:28 2013
New Revision: 1534437

URL: http://svn.apache.org/r1534437
Log:
cleanup the temp directory created and add ShutdownHook to cleanup the directory

Modified:
    tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/RunMojo.java

Modified: tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/RunMojo.java
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/RunMojo.java?rev=1534437&r1=1534436&r2=1534437&view=diff
==============================================================================
--- tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/RunMojo.java (original)
+++ tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/RunMojo.java Tue Oct 22 01:01:28 2013
@@ -124,11 +124,28 @@ public class RunMojo
     protected File getDocBase()
         throws IOException
     {
-        //
+        // https://issues.apache.org/jira/browse/MTOMCAT-239
+        // when running a jar docBase doesn't exists so create a fake one
         if ( !warSourceDirectory.exists() )
         {
             // we create a temporary file in build.directory
-            return createTempDirectory( new File( project.getBuild().getDirectory() ) );
+            final File tempDocBase = createTempDirectory( new File( project.getBuild().getDirectory() ) );
+            Runtime.getRuntime().addShutdownHook( new Thread()
+            {
+                @Override
+                public void run()
+                {
+                    try
+                    {
+                        FileUtils.deleteDirectory( tempDocBase );
+                    }
+                    catch ( Exception e )
+                    {
+                        // we can consider as safe to ignore as it's located in build directory
+                    }
+                }
+            } );
+            return tempDocBase;
         }
         return warSourceDirectory;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org