Stephan
Stephan

Reputation: 43013

Why Ant doesn't copy all files?

Here is a simple copy instruction:

<project name="Project Name" default="Default target">
    <!-- ... -->

    <copy todir="${tomcat.lib.dir}" verbose="true">
       <fileset dir="." includes="${dir_bdd},${p6spy_properties}" />
    </copy>

    <!-- ... -->    
</project>

where

${tomcat.lib.dir}=D:/Tomcat/Tomcat7/apache-tomcat-7.0.47-windows-x64/apache-tomcat-7.0.47/lib
${dir_bdd},${p6spy_properties}=../lib/ojdbc-10.2.0.3.jar,../lib/p6spy-2.2.0.jar,../lib/spy.properties

None of the files listed in includes parameter is copied to ${tomcat.lib.dir}.

File structure

/lib
   + ojdbc-10.2.0.3.jar
   + p6spy-2.2.0.jar
   + spy.properties
/scripts
   + build.xml

The build script is launched from Eclipse.

What am I missing?

Upvotes: 1

Views: 96

Answers (2)

Stephan
Stephan

Reputation: 43013

Here is how I solve my issue:

<copy todir="${tomcat.lib.dir}" verbose="true">
   <fileset dir="${lib_dir}" includes="${dir_bdd},${p6spy_properties}" />
</copy>

where

${lib_dir}=../lib
${dir_bdd},${p6spy_properties}=ojdbc-10.2.0.3.jar,p6spy-2.2.0.jar,spy.properties

Upvotes: 0

Tunaki
Tunaki

Reputation: 137064

The problem has to do with the fact that you're specifying a parent directory with .. for the includes attribute.

From the Ant documentation:

Only files found below that base directory are considered. So while a pattern like ../foo.java is possible, it will not match anything when applied since the base directory's parent is never scanned for files.

This applies in this case since the includes attribute holds an implicit PatternSet.

So you will have to change your ${dir_bdd} and ${p6spy_properties} properties so that:

${dir_bdd},${p6spy_properties}=lib/ojdbc-10.2.0.3.jar,lib/p6spy-2.2.0.jar,lib/spy.properties

Then, you can use

<copy todir="${tomcat.lib.dir}" verbose="true">
   <fileset dir=".." includes="${dir_bdd},${p6spy_properties}" />
</copy>

This way, the root of the fileset will be set to the parent directory and you can select the wanted files below it.

Upvotes: 1

Related Questions