ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <>
Subject Re: clarification
Date Mon, 04 Feb 2002 23:24:01 GMT
--- Stephen Huey <> wrote:
> With the include attribute on javac, we've sometimes
> tried to tell it to specifically include the
> in hopes that it would then go and
> try to compile only those files that the project
> depended on.

Ant's <javac> task just runs a Java compiler. It decides which files to
hand off to the compiler, but any additional files the compiler determines
it needs to compile in order to satisfy the compilation of the files it
was handed is up to the compiler itself -- the <javac> task is completely
out of things by that point.

If you point your <javac> task to just the one source file, it will only
hand it off to the compiler when its corresponding classfile either
doesn't exist or is older than the source file. It its classfile is
up-to-date, then it will seem as though your <javac> task was skipped --
but in fact, it simply determined there was nothing for it to do (run
'ant' with the -verbose flag to see output from <javac> saying why it's
not running the compile). So if you rely solely on specifying one source
file to try and compile all the dependent files, it's not going to work,
because <javac> is only going to check the existence/timestamp for that
one file, and if it's up-to-date, then nothing's going to happen. You can
use the nested <include>/<exclude> elements to include only those source
directories you want this particular <javac> task to deal with -- but you
should have it point to all the files you do want included. The first time
through (ie., having a clean output directory) the <javac> task will hand
the compiler all the included files -- after that, it will only hand off
those source files that are out-of-date with their corresponding
classfiles. (Note: You may also want to look into using the optional
<depend> task.)

Additionally, if your source files are part of a package, then the package
directory structure needs to match the package structure in order for the
<javac> task to find the corresponding classfiles, since the Java compiler
(note: the compiler, not Ant's <javac> task) will create subdirs according
to the package declared in the source file and output the classfile there.
For example, if your file is declared to be part of
'package com.widgets.ui;', then the file needs to live in, for example,
$HOME/src/java/com/widgets/ui, and the 'srcdir' attribute in your <javac>
task should point to the path leading up to where your package structure
begins, but not including any of the package-structure path elements (eg.,

Hope this helps,


Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions!

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message