tags:

views:

2569

answers:

3

If I have a fileset like this:

<fileset dir=".">
<exclude name="classes/*"/>
<include name="**/zar.class"/>   
</fileset>

The exclude takes precedence over the include and I don't end up with any classes. [since for this hypothetical example, zar.class is in the classes dir] I would like to include the zar file, even though it is in the classes dir.

I banged my head against this one for a while, reading about selectors, patternsets, filesets, trying to combine filesets, etc. but could not get it working.

Anyone know how to do this?

Thanks!

-Dan

A: 

I'm not sure exactly what you want but I think you were on the right track looking at pattersets: How about:

<patternset id="a">
  <exclude name="classes/*"/>
</patternset>

<patternset id="b">
  <include name="**/zar.class"/>  
</patternset>

<fileset dir=".">
  <patternset refid="a" />
  <patternset refid="b" />
</fileset>
Brian Fisher
+2  A: 

Why do you need the exclude element ?

<fileset dir=".">
  <include name="**/zar.class"/>   
</fileset>

should give you the exact set of files you are after: zar.class, and none of the other .class files in classes/.


Just put this in community wiki mode, because I am not sure, on second thought, that it is actually what you are after:
you may want everything, including classes/.../zar.class, except classes/....

My solution would only give you zar.class.

Please leave a comment: if this is not a good solution, I will remove it.

VonC
A: 

Maybe this could help you.

http://en.wikibooks.org/wiki/Apache_Ant/Fileset

I think you're not using it in the right way.

ForceMagic