You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by David McLeod <dm...@vocent.com> on 2003/01/21 21:20:59 UTC

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 the
prior <javac> task actually compiled something, and there doesn't seem to be
an easy way to detect whether any of the .class files have actually changed.

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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Dependent Tasks within a Single Target

Posted by Antoine Levy-Lambert <le...@tiscali-dsl.de>.
David,

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"
target
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$$"
to="classes\\\1.class"/>
      </uptodate>
   </target>
   <target name="compile" depends="check" unless="classes.uptodate">
      <mkdir dir="classes"/>
      <javac srcdir="src" destdir="classes"/>
   </target>
</project>

Antoine

----- Original Message -----
From: "David McLeod" <dm...@vocent.com>
To: <an...@jakarta.apache.org>
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
the
> prior <javac> task actually compiled something, and there doesn't seem to
be
> an easy way to detect whether any of the .class files have actually
changed.
>
> 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:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>