0

I am running a foreach loop over all directories that are below a root directory.

I want to exclude all directories with the name "src" and "bin".

How can i exclude those directories from the results?

There are multiple subdirectories in the root directory and the subdirectories could also contain subdirectories. I want to go through all directories below the root, except those with the names above.

I have tried the following and none have worked:

        <path>
            <dirset dir="../Apps/">
                <exclude name="*src*,*bin*"/>
            </dirset>
        </path>

        <path>
            <dirset dir="../Apps/">
                <exclude name="**/src*,**/bin*"/>
            </dirset>
        </path>

        <path>
            <dirset dir="../Apps/">
                <exclude name="**/src/**,**/bin/**"/>
            </dirset>
        </path>
prolink007
  • 33,872
  • 24
  • 117
  • 185

1 Answers1

2

This seems to work as expected (Ant 1.8.2 and ant-contrib 1.0b3) :

<target name="test">
    <foreach target="echo-folder-name" param="folder">
        <path>
            <dirset dir="../Apps/">
                <exclude name="**/bin/**" />
                <exclude name="**/src/**" />
            </dirset>
        </path>
    </foreach>
</target>

<target name="echo-folder-name">
    <echo>${folder}</echo>
</target>
grams
  • 649
  • 8
  • 8
  • I tried this option too earlier but with CSV. Why does the CSV not work? It says in the documentation that using CSV or spaces to separate the vales is supposed to work. Thanks, this worked separating into different tags. – prolink007 Oct 01 '12 at 16:00