ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject RE: How to return values from targets?
Date Wed, 16 Jul 2003 08:21:58 GMT
For <antcall>: if the called target sets a property, the caller will
not get that. I call that behaviour: "antcall creates a new namespace".
All set properties in that namespace get loss.

Therefore the only way (I know) to give values to the caller is via
persistent medium (e.g. file: <echo> + <property file>).

So your scenario would be something like that (written without testing):

<!-- file for using return values -->
<property name="b.file" name="b.properties"/>

<target name="B">
    <!-- do stuff -->
    <antcall target="D">
        <!-- where to store the return value -->
        <param name="rv"   value="b.rv"/>
        <param name="file" value="${file}"/>
    </antcall>
    <!-- load only that property -->
    <loadproperties srcFile="${b.file}">
        <filterchain>
            <linecontains>
                <contains value="b.rv="/>
            </linecontains>
        </filterchain>
    </loadproperties> 
    <!-- the conditional thing: using AntContrib -->
    <switch value="${b.rv}">
        <case value="true"> 
            <echo> The result was 'true' </echo>
        </case>
        <default>
            <echo> 'DEFAULT' </echo>
        </default>
    </switch>
</target>


<target name="D">
    <!-- got the param 'rv', so we can use that property -->
    <!-- set the return value -->
    <propertyfile file="${file}">
        <entry key="${rv}" value="true"/>
    </propertyfile>
</target>



But I never needed that behaviour. As you can see it needs lot of 
workarounds.


Jan



> -----Original Message-----
> From: Daniel Joshua [mailto:daniel.joshua@gridnode.com]
> Sent: Wednesday, July 16, 2003 10:09 AM
> To: 'Ant Users List'
> Subject: How to return values from targets?
> 
> 
> Hi,
> 
> Whats the best way to return values from targets?
> 
> 
> Here's my scenario in PseudoAnt:
> 
> target A
>   antcall B
>   antcall C
> 
> target B
>   do stuff
>   returnValue = antcall D
>   if (returnValue = true) then
>     do other stuff
> 
> target C
>   do stuff
>   returnValue = antcall D
>   if (returnValue = true) then
>     do other stuff
> 
> target D
>   do stuff
>   return true or false
> 
> 
> 
> Regards,
> Daniel
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message