ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rich Wagner" <>
Subject Re: just not getting it
Date Mon, 11 Aug 2003 04:23:33 GMT
One suggested addition to Conor MacNeill's example buildfile:

It's worth considering adding to the "compile" target so that it includes a 
"<depend>" task right before the "<javac>" task.  "<javac>" alone does an
but imperfect job of dependency checking and recompiling; preceding it with 
the appropriate <depend> makes the dependency checking almost perfect 
(though nothing can detect things like dependencies introduced because of 
run-time reflection...)

For example, say class A imports and uses class B.  Then say everything is 
compiled and brought up to date.  Next, say B is changed.  Without a 
preceding <depend> invocation, <javac> will see that is newer than 
B.class, so it'll recompile B.  However, <javac> will not determine that A 
should also be recompiled, even though A might call a method in B whose 
signature has changed.  When <depend> is used though, it will remove A.class 
when it sees that B has been modified, since <depend> (unlike <javac>) 
"knows" that A uses B.

Anyway, here's the documentation for <depend> :

Unfortunately, I don't have the time to add the exact <depend> element to 
the sample buildfile, but roughly speaking, the structure of the <depend> 
task mirrors that of the <javac> that follows it (especially in terms of the 
source and destination directories/files).  In addition though, I like to 
add "closure=true" and "cache=${cacheDir}" attributes to the <depend> task.

Anyway, I also encourage people to take the time to learn about Ant 
features.  I recently switched from using "make" to Ant, and I think Ant is 
far better...

Hope this helps,
Rich Wagner

>From: Conor MacNeill <>
>Reply-To: "Ant Users List" <>
>To: "Ant Users List" <>
>Subject: Re: just not getting it
>Date: Mon, 11 Aug 2003 11:25:34 +1000
>Here is a complete and relatively simple example of a full build file to
>compile and build a jar. This particular example uses a set of external
>libraries in the build. If you don;t need that, you can drop out the
>lib.classpath related stuff.
><project name="piston" default="jar">
>   <property name="src.dir" value="src"/>
>   <property name="build.dir" value="build"/>
>   <property name="lib.dir" value="lib"/>
>   <property name="jar.dir" value="jar"/>
>   <path id="lib.classpath">
>     <fileset dir="${lib.dir}"/>
>   </path>
>   <target name="compile">
>     <mkdir dir="${build.dir}"/>
>     <javac srcdir="${src.dir}" destdir="${build.dir}" debug="on">
>       <classpath refid="lib.classpath"/>
>     </javac>
>   </target>
>   <target name="jar" depends="compile">
>     <mkdir dir="${jar.dir}"/>
>     <jar destfile="${jar.dir}/piston.jar">
>       <fileset dir="${build.dir}"/>
>       <manifest>
>         <attribute name="Main-Class" value="com.codefeed.piston.Piston"/>
>       </manifest>
>     </jar>
>   </target>
>On Mon, 11 Aug 2003 06:44 am, Gregory Seidman wrote:
> >
> > Would someone please explain how to handle the simple example of a
> > directory/package tree full of .java source files to be built into a 
> > Once I have that toehold, I think I can start learning the rest.
> >

MSN 8 with e-mail virus protection service: 2 months FREE*

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message