You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Robert Davies <Ro...@astro.cf.ac.uk> on 2000/11/22 13:01:14 UTC

new ant user : exclude files

Hi

I am a new user to ant and would appreciate any help anybody could give. I am 
trying to exclude the files in the directory ./toolkit/tmp/*.java from 
compilation. I have tried the exclude tag but I cannot get it to work. I have 
also tried to use absolute path name but that does not seem to work. I am using 
ant 1.2 

Below is the build file code

********************************************************************************

<project name="Triana_src" default="build" basedir=".">

<target name="build">
	<javac srcdir="./util:./gui:./toolkit:" destdir="../../classes" 
deprecation="on" optimize="on">
		<exclude name="./toolkit/tmp/*.java" />
	</javac>
</target>


</project>

********************************************************************************

Thanks for any help

Rob


Re: new ant user : exclude files

Posted by Stefan Bodewig <bo...@apache.org>.
Robert Davies <Ro...@astro.cf.ac.uk> wrote:

> I am a new user to ant and would appreciate any help anybody could
> give. I am trying to exclude the files in the directory
> ./toolkit/tmp/*.java from compilation. I have tried the exclude tag
> but I cannot get it to work.

[...]

> <javac srcdir="./util:./gui:./toolkit:" destdir="../../classes" 
>        deprecation="on" optimize="on"> 
>   <exclude name="./toolkit/tmp/*.java" /> 
> </javac>

it doesn't work because the files in ./toolkit/tmp don't match the
pattern you specify. Patterns are relative to a base directory, so
what you are actually excluding here is

./util/./toolkit/tmp/*.java
./gui/./toolkit/tmp/*.java
./toolkit/./toolkit/tmp/*.java

make your exclude pattern tmp/*.java and it should work (but also
exclude util/tmp/*.java and gui/tmp/*.java if present).

Three notes:

(1) You don't need to prefix your relative filenames with ./ this is
what Ant (1.2) assumes anyway.

(2) If a class you are going to compile references another class that
lives in toolkit/tmp/, this one will be compiled as well, even though
you've ordered to exclude it.

(3) <javac> expects to be pointed to the root of a package hierarchy,
so the files living directly in the toolkit, util or gui directories
are expected to be in the (unnamed) default package. No big harm will
be done if you don't obey to this rule, except that Ant will always
recompile all files.

Stefan