ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dale Anson <>
Subject Re: Trouble using user properties in custom Ant task, help!!!
Date Fri, 28 Feb 2003 19:30:32 GMT
Actually, I don't think I ever got around to posting the antcallback 
task, which is analogous to antcall. There is an antfetch, which is 
analogous to the ant task. These are actually pretty straight forward 
tasks, for the most part they are copy and paste from antcall and ant. 
The difference is that they copy some properties from the child project 
to the parent at the end of the execution. Unfortunately, I couldn't 
just extend antcall and ant because they both null the reference to the 
child project at the end of the execute methods. You don't get all the 
properties from the antcall back, you only get the ones you ask for. 
Here's a simple example based on Barry's original question:

<antfetch antfile="${ant.file}" target="run.client" return="exitCode"/>
<echo message="This is the exit code of the client: ${exitCode}"/>

This would print out the exit code as expected.

Dale Anson

Dominique Devienne wrote:

>That said, I think the Antelope project on SF added a custom <antcall> task
>allowing just that, returning properties to the parent process. But this is
>very unlikely to ever make it to Ant proper. --DD
>-----Original Message-----
>From: Dominique Devienne [] 
>Sent: Thursday, February 27, 2003 5:24 PM
>To: 'Ant Developers List'
>Subject: RE: Trouble using user properties in custom Ant task, help!!!
>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" />
>    </myjava>
>    <echo message = "EXIT CODE is ${exitCode}" />
>  </target>
>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">
>    <parallel>
>      <antcall target = "run.server" />
>      <sequential>
>        <sleep seconds = "5" />
>        <antcall target = "run.client" />
>        <echo message = "This is the exit code of the client: ${exitCode}"
>        <antcall target = "stop.server" />
>      </sequential>
>    </parallel>
>  </target>
>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!
>To unsubscribe, e-mail:
>For additional commands, e-mail:
>To unsubscribe, e-mail:
>For additional commands, e-mail:

View raw message