ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antoine Levy-Lambert" <>
Subject Re: Dependent Tasks within a Single Target
Date Tue, 21 Jan 2003 21:29:58 GMT

You might want to use the uptodate task before the javac task to find out if
your classes are up to date
If you set a property called for instance "classes.uptodate" only if the
classes are up to date before invoking compile,
you can change your build.xml and add an unless attribute for your "compile"
In this case, you will always do javac and then echo, unless your classes
are up to date
You should give it a try

Here is a sample which works

<project name="testuptodate" default="compile" basedir=".">
   <target name="check">
      <!-- <touch file="classes/bonjour.class" datetime="06/28/2000 2:02
pm"/> -->
      <uptodate property="classes.uptodate">
         <srcfiles dir= "." includes="src/**.java"/>
         <mapper type="regexp" from="src\\(.*)\.java$$"
   <target name="compile" depends="check" unless="classes.uptodate">
      <mkdir dir="classes"/>
      <javac srcdir="src" destdir="classes"/>


----- Original Message -----
From: "David McLeod" <>
To: <>
Sent: Tuesday, January 21, 2003 9:20 PM
Subject: Dependent Tasks within a Single Target

> I have a fairly simple compile target that looks something like this:
>     <target name="compile" depends="speech, enterprise">
>         <echo message="*** Compiling ${moduleName} module."/>
>         <mkdir dir="${build}"/>
>         <javac srcdir="${source}" destdir="${build}"
> classpath="${myClassPath}" includes="${rootPath}/**/*.java"/>
>         <echo message="${moduleName} compiled ${buildTimestamp}"
> file="${timestampFile}"/>
>     </target>
> The problem is, I don't want the last <echo> task to be executed UNLESS
> prior <javac> task actually compiled something, and there doesn't seem to
> an easy way to detect whether any of the .class files have actually
> I understand about dependent TARGETS, but I can't seem to find any
> information in the manuals or on the FAQ about dependent TASKS within a
> single target.  I realize that I could write a special task to handle this
> case, but I am hoping that there is already a mechanism somewhere in Ant
> that I have just missed.  Any help would be greatly appreciated.
> Thank you.
> David McLeod
> --
> To unsubscribe, e-mail:   <>
> For additional commands, e-mail: <>

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

View raw message