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 <[EMAIL PROTECTED]>
> An: "Ant Users List" <[email protected]>
> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to