You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Kief Morris <ki...@bitBull.com> on 2000/10/19 13:12:35 UTC

Unnecessary compilation

I've found that all of my source files are being recompiled by the
<javac> target every time, regardless of whether I've changed them.
According to the docs, "Only Java files that have no corresponding
class file or where the class file is older than the java file will be
compiled." However, I check the date on a .class file and the
corresponding .java file and verify the .class is older, then run
build again and the .class file now has a newer timestamp.

Any suggestions? Does this work correctly for other people?
I'm using a relatively recent build of Ant 1.2 (less than a week old),
Sun JDK 1.1.8 on Solaris 7.

Thanks,
Kief


            The Wildest party on the Net is on!
                     http://www.Wild5.com



RE: Unnecessary compilation

Posted by Kief Morris <ki...@bitBull.com>.
Conor MacNeill typed the following on 23:41 19/10/00 +1100
 >If you are using ant 1.2rc1, you can try using the -debug flag to ant. It
 >will then tell you why it is decising to recompile a class.

Aha, very useful, thanks.

 >Change this to
 >
 ><javac srcdir="${source}"
 >       includes="com/bitbull/audience/visitor/*.java"
 >       ...
 >
 >and it will work.

Indeed it does, previously it was checking for the target .class file in
the root of the destdir.

 >You may be surprised, however, if the compiler (not ant)
 >decides to compielr other classes in your tree to satisfy class
 >dependencies.

I'll have to watch for that. I'm trying to reduce the dependencies
between packages to a tightly defined set.

Thanks for the help!

Kief


            The Wildest party on the Net is on!
                     http://www.Wild5.com



Re: Unnecessary compilation

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "KM" == Kief Morris <ki...@bitBull.com> writes:

 KM> I'm very specifically compiling only the files in a single
 KM> directory, because I have subpackages which have different
 KM> dependencies in their classpath, and I need to enforce these
 KM> rigidly. Could this be preventing Ant from determining the
 KM> package?

Yes, this is the problem. Try something like

<javac srcdir="${source}"
       destdir="${build}" debug="${debug-flag}" optimize="${opt_flag}">
  <include name="/com/bitbull/audience/visitor/*.java" /> 
  <classpath> 
    <pathelement location="${jlib}/classes.zip"/> 
    <pathelement location="${jlib}/storage_if.jar"/> 
    <pathelement location="${jlib}/util.jar"/> 
  </classpath> 
</javac>


This should have the effect you want to see.

Stefan

RE: Unnecessary compilation

Posted by Conor MacNeill <co...@m64.com>.
Kief,

If you are using ant 1.2rc1, you can try using the -debug flag to ant. It
will then tell you why it is decising to recompile a class.
> My project does meet these requirements, but perhaps Ant is
> getting confused
> by the way I am specifying the files to compile. My javac target is:
>
> <javac srcdir="${source}/com/bitbull/audience/visitor"
>                  includes="*.java"
>                  destdir="${build}"
>                  debug="${debug-flag}"
>                  optimize="${opt_flag}">
>          <classpath>
>                  <pathelement location="${jlib}/classes.zip"/>
>                  <pathelement location="${jlib}/storage_if.jar"/>
>                  <pathelement location="${jlib}/util.jar"/>
>          </classpath>
> </javac>
>
Change this to

<javac srcdir="${source}"
       includes="com/bitbull/audience/visitor/*.java"
       ...

and it will work. You may be surprised, however, if the compiler (not ant)
decides to compielr other classes in your tree to satisfy class
dependencies.

Conor


Re: Unnecessary compilation

Posted by Kief Morris <ki...@bitBull.com>.
Stefan Bodewig typed the following on 13:27 19/10/00 +0200
 >>>>>> "KM" == Kief Morris <ki...@bitBull.com> writes:
 >
 > KM> I've found that all of my source files are being recompiled by
 > KM> the <javac> target every time,
 >
 >Have you read
 ><http://jakarta.apache.org/jyve-faq/Turbine/screen/DisplayQuestionAnswer/act>ion/SetAll/project_id/2/faq_id/16/topic_id/72/question_id/740>?
 >I think you will find your answer there.

Thanks for the reference. I'm not sure it has the answer, though,
it says "To make this work, your classes must reside in a directory
structure matching your package structure and javac's srcdir attribute
must point to it."

My project does meet these requirements, but perhaps Ant is getting confused
by the way I am specifying the files to compile. My javac target is:

<javac srcdir="${source}/com/bitbull/audience/visitor"
                 includes="*.java"
                 destdir="${build}"
                 debug="${debug-flag}"
                 optimize="${opt_flag}">
         <classpath>
                 <pathelement location="${jlib}/classes.zip"/>
                 <pathelement location="${jlib}/storage_if.jar"/>
                 <pathelement location="${jlib}/util.jar"/>
         </classpath>
</javac>

I'm very specifically compiling only the files in a single directory, because
I have subpackages which have different dependencies in their classpath,
and I need to enforce these rigidly. Could this be preventing Ant from
determining the package?

Thanks,
Kief



            The Wildest party on the Net is on!
                     http://www.Wild5.com



Re: Unnecessary compilation

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "KM" == Kief Morris <ki...@bitBull.com> writes:

 KM> I've found that all of my source files are being recompiled by
 KM> the <javac> target every time,

Have you read
<http://jakarta.apache.org/jyve-faq/Turbine/screen/DisplayQuestionAnswer/action/SetAll/project_id/2/faq_id/16/topic_id/72/question_id/740>?
I think you will find your answer there.

Cheers

        Stefan