ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antoine Levy-Lambert" <anto...@gmx.de>
Subject Re: Only deleting an empty directory (-tree)
Date Mon, 30 May 2005 11:55:46 GMT
Hello Juergen,

now got it

this works with ant 1.6.4, + beanshell 
from http://www.beanshell.org/
and bsf from http://jakarta.apache.org/bsf/

Cheers,

Antoine

(not sure if the import *; is the nicest, but it works ...)

<project name="test">
<script language="beanshell">
      import *;
      public class EmptyDirSelector extends DataType implements FileSelector
{
 		public boolean isSelected(File basedir, java.lang.String filename, File
file)
            throws BuildException {
                 if (!file.isDirectory()) {
                    return false;
                    }
                java.lang.String[] aaa = file.list();
                if (aaa != null) {
                	if (aaa.length == 0) {
                	    return true;
                	}
                }
                return false;
            }
      }
      project.addDataTypeDefinition("emptydirselector",
EmptyDirSelector.class);
    </script>
    <mkdir dir="d:/test1/test2/test3/test4"/>
    <mkdir dir="d:/test1/test2/test3/test5"/>
    <echo file="d:/test1/test2/test3/test5/test5.txt">
bonjour
    </echo>
    <delete includeemptydirs="true">
    <fileset dir="d:/test1">
        <emptydirselector/>
    </fileset>
    </delete>
</project>

> --- Ursprüngliche Nachricht ---
> Von: Juergen Damke <DAMKE@de.ibm.com>
> An: "Ant Users List" <user@ant.apache.org>
> Betreff: Only deleting an empty directory (-tree)
> Datum: Mon, 30 May 2005 09:16:29 +0200
> 
> I'm searching for a task which traverses a directorytree and removes 
> all empty directories, but leaves those which have any contents.
> 
> Should work unter *NIX and Windows, so a java Task is preferred.
> 
> Mit freundlichen Grüßen / With best regards
> Jürgen Damke
> Portal Automated Function Verification Tests
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message