ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conor MacNeill" <>
Subject Re: javac destdir problem
Date Sat, 11 Aug 2001 05:50:22 GMT

----- Original Message -----
From: "T Master" <>
> OK, Here is a problem/bug i've discovered. Makes sense, but then again it
> doesn't.  I would prefer a modification.
> <javac destdir="${}"
>              debug="off"
>              verbose="false">
>             <classpath refid="project.class.path"/>
>             <src path="${project.src.dir}"/>
>             <include name="**/*.java"/>
>         </javac>
> That's my code.  My java files have packages.   the src.path property
> to the correct package to compile.
> Now Ant will check if the class files are in   .  If
> the source files wll be compiled.
> The is the package space to put the class files in.  It
> corresponds to the java package.  Note: java files and class files belong
> differernt root dirs.

This behaviour is related to the FAQ entry

The following all need to be set up
1. The destdir must be set to the root of your build area
2. The srcdir must be set to the root of your source area - your package
3. If you want to control which files are passed to the compiler, use the
includes - i.e. dont include "**/*.java", include something like

> Conclusion:
> When the destdir uses the package space, the class files are found, and
> compilation will not occur again (which is correct since they exist).
> However, after compilation, the destdir is considered the root of the
> package space, so the package heirarchy is reconstructed, and thus the
> files are put into the wrong location.

OK, in tis situation Ant thinks that your classes exist in the root package
space. It dtermines this by looking relative to the src and dest dirs.
Since the class files appear in the corresponding place in the dest tree as
the java files occur in the source tree, Ant concludes the files are up to
date. The compiler, however, when it does compile these files, will read
the source (Ant doesn't) and see the actual package and store the class
files relative to the root of the dest dir.

> If, the destdir is the root of the package space, the existing class
> won't be detected, but the compiled files will be placed correctly.
> The classpath does include the root dir of the class files location too,
> that makes no difference.

OK, here it is Ant's check that cause the compile. Ant can't find your
class files in the same position in the dest tree as the java files exist
in the source tree. Ant concludes that the class files are missing and need
to be recompiled. The compiler, now being given the correct dest root, puts
the files in the right place.

> Anyone know if this is a bug, or is there a good workaround available?

Not a bug - see above.


View raw message