Ant Copy Empty Directories

I'm still very new to ant, and although I know coldfusion, I am not very good at java conventions, but I know that ant is built using java conventions. In doing so, I work on the ant process to copy the project to a temporary folder, change the code in the project, and then move the temp directory to FTP. I am trying to exclude all my git, eclipse and ant files from a copy so that my test platform is not cluttered. I am setting the target for copying, but it seems that ant not only ignores my exceptions (which I am sure I wrote wrong), but it is only copying top-level directories and files. There is no recursive copy. My current goal:

<target name="moveToTemp" depends="init"> <delete dir="./.ant/temp" /> <mkdir dir="./.ant/temp" /> <copy todir="./.ant/temp"> <fileset dir="."> <include name="*" /> <exclude name=".*/**" /> <exclude name=".*" /> <exclude name="build.xml" /> <exclude name="settings.xml" /> <exclude name="WEB-INF/**" /> </fileset> <filterset> <filter token="set(environment='design')" value="set(environment='testing')" /> </filterset> </copy> </target> 

I know that I do not make my exceptions, but I do not know what I do with them. I see double asterisks (**) used all the time in ant, but I can't figure it out

+7
source share
1 answer

By default, the Ant fileset will (recursively) include all files in the specified directory, which is equivalent to:

 <include name="**/*" /> 

In that implied include. If you provide include, it overrides implicit.

Turn on

 <include name="*" /> 

It says "matches any file in the file set directory", but this eliminates the traversal of subdirectories, hence your problem. Only top-level files and directories are copied.

See Patterns in Ant docs for directory-based tasks: ** matches any directory tree (zero or more directories).

In your case, you can simply remove the "include" to use the implicit "include all".

Suggest you also examine the defaultexcludes task, which allows you to configure this type once for the entire project.

+7
source

All Articles