Delete a folder using starts with in ANT

141 views Asked by At

I am comparing 2 folders A and B, and wanted to delete folders and jars present in B which are not present in folder A.

I have written the logic to get needed files to delete, but i do not wanted to delete the directory and jars starting with "com.ibm".

For that I have written delete task as below:

<delete>
    <dirset dir="D://mypath/plugins<Filename to delete> excludes="**/com.ibm.*/**" />
</delete>

I have tried the excludes with the scenarios like:

excludes="**/com.ibm.*/**"
excludes="**/com.ibm.*"
excludes="com.ibm.*"
excludes="com.ibm.*/**"

But nothing works for me (It is not deleting any folders/files). Any help would be highly appreciated. Thanks !

1

There are 1 answers

0
guleryuz On

you should use fileset instead and specify includeemptydirs="true" of delete.

<project default="init" name="My Project">

    <target name="init">
        <delete verbose="true" includeemptydirs="true">
            <fileset dir="/home/guest/Desktop/plugins" defaultexcludes="no">
                <exclude name="com.ibm.*"/>
                <exclude name="com.ibm.*/**"/>
            </fileset>
        </delete>
    </target>

</project>