ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Barry Lulas" <>
Subject Trouble using user properties in custom Ant task, help!!!
Date Thu, 27 Feb 2003 22:57:34 GMT
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 =
      <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:

  <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!
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message