You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ni...@apache.org on 2004/05/23 07:47:51 UTC

svn commit: rev 20233 - in avalon/trunk/tools/magic/clean: . src src/dist src/xdocs

Author: niclas
Date: Sat May 22 22:47:50 2004
New Revision: 20233

Added:
   avalon/trunk/tools/magic/clean/
   avalon/trunk/tools/magic/clean/build.properties
   avalon/trunk/tools/magic/clean/src/
   avalon/trunk/tools/magic/clean/src/dist/
   avalon/trunk/tools/magic/clean/src/dist/build.bsh
   avalon/trunk/tools/magic/clean/src/dist/build.properties
   avalon/trunk/tools/magic/clean/src/xdocs/
Log:
Added a clean plugin.

Added: avalon/trunk/tools/magic/clean/build.properties
==============================================================================
--- (empty file)
+++ avalon/trunk/tools/magic/clean/build.properties	Sat May 22 22:47:50 2004
@@ -0,0 +1,2 @@
+ 
+project.name = clean

Added: avalon/trunk/tools/magic/clean/src/dist/build.bsh
==============================================================================
--- (empty file)
+++ avalon/trunk/tools/magic/clean/src/dist/build.bsh	Sat May 22 22:47:50 2004
@@ -0,0 +1,56 @@
+
+import java.io.File;
+import java.io.IOException;
+
+import java.util.StringTokenizer;
+
+import org.apache.merlin.magic.AbstractPlugin;
+
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.ServiceException;
+
+public class CleanPlugin extends AbstractPlugin
+    implements Serviceable
+{
+    private Object m_PreparePlugin;
+        
+    public void service( ServiceManager man )
+        throws ServiceException
+    {
+        m_PreparePlugin = man.lookup( "prepare" );
+    }
+    
+    public void clean()
+        throws IOException
+    {   
+        notifyPreMethod( "clean" );
+        delete();    
+        notifyPostMethod( "clean" );
+    }
+    
+    private void delete()
+        throws IOException
+    {
+        File basedir = m_Context.getProjectDir();
+        String targets = m_Context.getProperty( "clean.build.dest.dirs" );
+        StringTokenizer st = new StringTokenizer( targets, " ,", false );
+        while( st.hasMoreTokens() )
+        {
+            File f = new File( basedir, st.nextToken() );
+            delete( f );
+        }
+    }
+    
+    private void delete( File f )
+        throws IOException
+    {
+        if( f.isDirectory() )
+        {
+            File[] content = f.listFiles();
+            for( int i= 0 ; i < content.length ; i++ )
+                delete( content[i] );
+        }
+        f.delete();
+    }
+}   

Added: avalon/trunk/tools/magic/clean/src/dist/build.properties
==============================================================================
--- (empty file)
+++ avalon/trunk/tools/magic/clean/src/dist/build.properties	Sat May 22 22:47:50 2004
@@ -0,0 +1,2 @@
+
+clean.build.dest.dirs = ${prepare.dest.dir}

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org