You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by T Master <tm...@iknowledgeinc.com> on 2001/08/10 20:42:32 UTC

javac destdir problem

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.


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.

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.

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

T Master


Re: javac destdir problem

Posted by T Master <tm...@iknowledgeinc.com>.
Thanks.  I understand now Conor.

Question: Can I use a patternset I have predefined for use with javac?
Also, I couldn't get my patternsets to work with <jar> (parsed, but settings
ignore completely)

Note, the <jar> task states it supports all fileset attributes, and even
includes an example using a fileset.  The <javac> task however does not
provide an example of a nest fileset, but also states it supports all
fileset attributes verbatim.

This is the error message I get:
 +Target: compileProject2
   +Task: javac
appserver-build.xml [132] Class org.apache.tools.ant.taskdefs.Javac doesn't
support the nested "fileset" element

My objective is to have a fileset for cleaning (works beautifully), and
using same for jar'ing, and javac'ing.  Cod re-use!

T Master.



----- Original Message -----
From: "Conor MacNeill" <co...@cortexebusiness.com.au>
To: <an...@jakarta.apache.org>
Sent: Friday, August 10, 2001 11:50 PM
Subject: Re: javac destdir problem


> Hi,
>
> ----- Original Message -----
> From: "T Master" <tm...@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"
>



Re: javac destdir problem

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
Hi,

----- Original Message -----
From: "T Master" <tm...@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