prolink007
prolink007

Reputation: 34544

ant exclude directories in dirset

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>

Upvotes: 0

Views: 2740

Answers (1)

grams
grams

Reputation: 659

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>

Upvotes: 2

Related Questions