ant-user mailing list archives

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

----- Original Message -----
From: "T Master" <tmaster@iknowledgeinc.com>
>
> OK, Here is a problem/bug i've discovered. Makes sense, but then again it
> doesn't.  I would prefer a modification.
>
> <javac destdir="${project.build.dir}"
>              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
refers
> to the correct package to compile.
> Now Ant will check if the class files are in project.build.dir   .  If
not,
> the source files wll be compiled.
>
> The project.build.dir is the package space to put the class files in.  It
> corresponds to the java package.  Note: java files and class files belong
in
> differernt root dirs.
>
>

This behaviour is related to the FAQ entry
http://jakarta.apache.org/ant/faq.html#always-recompiles

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
space
3. If you want to control which files are passed to the compiler, use the
includes - i.e. dont include "**/*.java", include something like
include="org/apache/ant/**/*.java"

> 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
class
> 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
files
> 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,
and
> 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.

Conor



Mime
View raw message