You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Scott Ellsworth <sc...@alodar.com> on 2001/10/02 22:34:12 UTC

javac include that avoids rebuilding everything?

Howdy, all.

I note that the task for javac says:

"If you include part of your package-structure inside the srcdir-attribute 
(or nested src-elements) Ant will start to recompile your sources every 
time you call it."

This is exactly what ANT is doing to me at the moment, and I cannot figure 
out how to rewrite my build.xml file to make it work.

My directory structure for this is:

-org
--metagraph
---lib
---app
----experiment

My build.xml file is in foo/org/metagraph/app/experiment.  Up at the top, I 
define <property name="src" value="."/>

I want to compile all of the files in experiment, using various libs in 
lib.  The following javac task does it, but as the documentation warns, it 
recompiles everything each time.

   <target name="compile-debug-old" depends="depend">
     <!-- Compile the java code from ${src} into ${build} -->
     <javac
       srcdir="${src}"
       destdir="${build-debug}"
       classpath="${utilclasspath}"
     />
   </target>

I tried changing it to:

   <target name="compile-debug" depends="depend">
     <!-- Compile the java code from ${src} into ${build} -->
     <javac
       srcdir="${src}/test"
       includes="org/metagraph/app/import/**"
       destdir="${build-debug}"
       classpath="${utilclasspath}"
     />
   </target>

where test is a directory with nothing in it, but then it did not recompile 
anything.

I must be missing something basic here.  For various reasons, the build.xml 
file has to be in org.metagraph.app.experiment, and the build must be run 
from there, but this should not be an insolvable problem, right?

The complete file which rebuilds the world, as the documentation warns, is 
attached below.

<project name="experiment" default="dist" basedir=".">

   <!-- set global properties for this build -->
   <property name="basemgdir" value="../../../.."/>
   <property name="src" value="."/>
   <property name="build" value="build"/>
   <property name="build-debug" value="build/debug"/>
   <property name="depcache-debug" value="${build}/debug-depcache"/>
   <property name="build-release" value="build/release"/>
   <property name="depcache-release" value="${build}/release-depcache"/>
   <property name="libdir" value="${basemgdir}/org/metagraph/lib"/>
   <property name="utilclasspath" 
value="${libdir}/metagraph.jar:${libdir}/mysql.jar:${libdir}/log4j.jar:${libdir}/xerces.jar:${libdir}/jdom.jar"/>
   <property name="dist"  value="dist"/>
   <!-- property name="build.compiler" value="jikes"/ -->

   <target name="init">
     <!-- Create the time stamp -->
     <tstamp/>
     <!-- Create the build directory structure used by compile -->
     <mkdir dir="${build-debug}"/>
     <mkdir dir="${depcache-debug}"/>
     <mkdir dir="${build-release}"/>
     <mkdir dir="${depcache-release}"/>
     <!-- Create the dist structure used for results -->
     <mkdir dir="${dist}"/>
   </target>

   <target name="depend" depends="init">
     <depend srcdir="${src}"
       destdir="${build-debug}"
       cache="${depcache-debug}"
       closure="yes"
     />

     <depend srcdir="${src}"
       destdir="${build-release}"
       cache="${depcache-release}"
       closure="yes"
     />
   </target>

   <target name="compile-debug" depends="depend">
     <!-- Compile the java code from ${src} into ${build} -->
     <javac
       debug="on"
       optimize="off"
       srcdir="${src}"
       destdir="${build-debug}"
       classpath="${utilclasspath}"
     />
   </target>

   <target name="compile-release" depends="depend">
     <!-- Compile the java code from ${src} into ${build} -->
     <javac
       debug="off"
       optimize="on"
       srcdir="${src}"
       destdir="${build-release}"
       classpath="${libdir}/metagraph.jar:${libdir}/mysql.jar:${libdir}/log4j.jar:${libdir}/xerces.jar:${libdir}/jdom.jar"
     />
   </target>

   <target name="dist-debug" depends="compile-debug">
     <!-- Put everything in ${build-debug} into the 
expImport-${DSTAMP}-debug.jar file -->
     <jar
       jarfile="${dist}/expImport-${DSTAMP}-debug.jar"
       basedir="${build-debug}"
       compress="false"
     />
   </target>

   <target name="dist-release" depends="compile-release">
     <!-- Put everything in ${build-release} into the 
expImport-${DSTAMP}.jar file -->
     <jar
       jarfile="${dist}/expImport-${DSTAMP}.jar"
       basedir="${build-release}"
       compress="true"
     />
   </target>

   <target name="dist" depends="dist-debug,dist-release">
   </target>

   <target name="clean">
     <!-- Delete the ${build} and ${dist} directory trees -->
     <delete dir="${build}"/>
     <delete dir="${dist}"/>
   </target>
</project>

Scott
Scott Ellsworth
scott@alodar.com


Re: javac include that avoids rebuilding everything?

Posted by Scott Ellsworth <sc...@alodar.com>.
At 02:50 PM 10/2/2001 -0700, Diane Holt wrote:
>--- Scott Ellsworth <sc...@alodar.com> wrote:
> > My build.xml file is in foo/org/metagraph/app/experiment.  Up at the
> > top, I define <property name="src" value="."/>
>
>You'll need to point "srcdir" (ie., your ${src}) back up to your "foo"
>directory. Either use relatives going back up...

Aha!  I chose the relative option, though both did the same thing.

>Then include the name of the package in the includes, the way you have it
>here:

Aha again!

Things appear to be building correctly now for that project.

Thanks!

Scott
Scott Ellsworth
scott@alodar.com


Re: javac include that avoids rebuilding everything?

Posted by Diane Holt <ho...@yahoo.com>.
--- Scott Ellsworth <sc...@alodar.com> wrote:
> My build.xml file is in foo/org/metagraph/app/experiment.  Up at the
> top, I define <property name="src" value="."/>

You'll need to point "srcdir" (ie., your ${src}) back up to your "foo"
directory. Either use relatives going back up or, if you have a property
that represents the top of your work area (eg., ${TOP}), use ${TOP}/foo.
Then include the name of the package in the includes, the way you have it
here:

>        includes="org/metagraph/app/import/**"

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Listen to your Yahoo! Mail messages from any phone.
http://phone.yahoo.com