Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude a directory from ant fileset, based on directories contents

Tags:

ant

fileset

How can I create an ant fileset which excludes certain directories based on the contents of the directory?

I use ant to create a distribution jar which has each localization in separate directories, some of which are incomplete and should not be released.

I would like to add something to the directory (for example a file named incomplete.flag) so that ant excludes the directory. Then I can delete the file when translation is complete, and include it in the build without modifying build.xml.

Given this directory structure:

proj + locale   + de-DE   + en-US   + fr-FR 

This fileset excludes all incompelte.flag files, but how can I exclude the entire directories that contain them?

  <fileset dir="${basedir}">     <include name="locale/"/>     <exclude name="locale/*/incomplete.flag">   </fileset> 

I can write an ant task if need be, but I'm hoping the fileset can handle this use case.

like image 209
Chadwick Avatar asked Feb 09 '10 22:02

Chadwick


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 dir 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.

What is Ant build XML?

Ant uses an xml file for its configuration. The default file name is build. xml . Ant builds are based on three blocks: tasks, targets and extension points. A task is a unit of work which should be performed and constitutes of small atomic steps, for example compile source code or create Javadoc.


2 Answers

The following approach works for me:

<exclude name="**/dir_name_to_exclude/**" /> 
like image 174
Sasha Avatar answered Oct 23 '22 19:10

Sasha


You need to add a '/' after the dir name

<exclude name="WEB-INF/" /> 
like image 27
Nicolas Robert-Dehault Avatar answered Oct 23 '22 20:10

Nicolas Robert-Dehault