Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have an Ant INCLUDE fileset take priority over an EXCLUDE

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?

like image 992
user41762 Avatar asked Jan 09 '09 06:01

user41762


People also ask

What does the default excludes parameter of the FileSet element do?

Description. Alters the default excludes for all subsequent processing in the build, and prints out the current default excludes if desired.

What is FileSet in Ant?

A FileSet is a group of files. These files can be found in a directory tree starting in a base directory and are matched by patterns taken from a number of PatternSets and Selectors. PatternSets can be specified as nested <patternset> elements.


1 Answers

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.

like image 160
2 revs Avatar answered Sep 29 '22 00:09

2 revs