ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <>
Subject RE: Trouble using user properties in custom Ant task, help!!!
Date Thu, 27 Feb 2003 23:24:10 GMT
Ant 101: Properties set during an <antcall> are not visible to the callee
(which lives in a different Project). This has nothing to do with using
<parallel>, <sequential>, or your custom task for that matter. --DD

-----Original Message-----
From: Barry Lulas [] 
Sent: Thursday, February 27, 2003 4:58 PM
Subject: Trouble using user properties in custom Ant task, help!!!

I have a custom task that extends the Java task because I want to be able to
conditionalize on the exit code of the Java application.  I can't use the
exec task because I have the need to specify JVM parameters and also have a
very complicated classpath, for which I use a series of path elements.  My
custom task simply looks at the exit code of the application and sets the
exitCode property.  Simple enough.

Okay, now the problem comes in.  I have a target that uses this custom task:

  <target name = "run.client" depends = "run.initialize">
    <taskdef name = "myjava" classname = ""
classpathref = "project.class.path" />
    <myjava classname = "" classpathref =
"project.class.path" fork = "true">
      <jvmarg value = "-Djava.library.path=${dir.bin" />

    <echo message = "EXIT CODE is ${exitCode}" />

This all works fine.  However, if I invoke this target from another target,
using antcall, then the property doesn't seem to be set in my calling

  <target name = "run">
      <antcall target = "run.server" />

        <sleep seconds = "5" />
        <antcall target = "run.client" />

        <echo message = "This is the exit code of the client: ${exitCode}"

        <antcall target = "stop.server" />

The output from Ant looks like this:

   [echo] Server running...
  [echo] EXIT CODE is 1
  [echo] This is the exit code of the client: ${exitCocde}

As you can see, it treats the first echo command like the property is set,
it shows the value.  However, in the calling target it treats it like it
hasn't been set.  Can this be a by-product of using the parallel and
sequential tasks?

Also, can somebody show me an example of how to conditionalize a call based
on the exitCode property, if and when it is properly set?

Thanks for any help!

View raw message