You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Will Dyke <wi...@bbc.co.uk> on 2001/08/22 16:17:42 UTC
User property overridden in nested ant scripts
I wish to use a command line property occasionally,
to override that set in a 'wrapper' script, that
in turn calls the main script.
However, the property set in the wrapper script appears to
override that set on the command line once the main
script is called.
As an example, I have two scripts, dummywrapper.xml,
and dummy.xml
========== dummywrapper.xml ===============
<project name="fakebuild" default="wrapper" basedir=".">
<target name="wrapper">
<ant antfile="dummy.xml" target="build-deploy">
<property name="whoami" value="apps"/>
</ant>
</target>
</project>
================ dummy.xml ================
<project name="fakebuild" default="build-deploy" basedir=".">
<target name="build-deploy">
<property name="whoami" value="apps"/>
<echo message="${whoami}"/>
</target>
</project>
If I call dummy.xml, the command line property works fine,
and the output is wd, as expected.
----
C:\ant\1.4b2\bin>ant -buildfile dummy.xml -Dwhoami=wd
Buildfile: dummy.xml
build-deploy:
[echo] wd
BUILD SUCCESSFUL
Total time: 0 seconds
----
If, however, I call the wrapper script, the output is
apps.
-----
C:\ant\1.4b2\bin>ant -buildfile dummywrapper.xml -Dwhoami=wd
Buildfile: dummywrapper.xml
wrapper:
build-deploy:
[echo] apps
BUILD SUCCESSFUL
Total time: 0 seconds
-----
Any ideas?
Thanks,
Will Dyke
This e-mail, and any attachment, is confidential. If you have received
it in error, please delete it from your system, do not use or disclose
the information in any way, and notify me immediately. The contents of
this message may contain personal views which are not the views of the
BBC, unless specifically stated.
Re: User property overridden in nested ant scripts
Posted by Don Taylor <do...@yahoo.com>.
--- Will Dyke <wi...@bbc.co.uk> wrote:
> I wish to use a command line property occasionally,
> to override that set in a 'wrapper' script, that
> in turn calls the main script.
>
> However, the property set in the wrapper script appears to
> override that set on the command line once the main
> script is called.
>
> As an example, I have two scripts, dummywrapper.xml,
> and dummy.xml
>
> ========== dummywrapper.xml ===============
> <project name="fakebuild" default="wrapper" basedir=".">
> <target name="wrapper">
> <ant antfile="dummy.xml" target="build-deploy">
> <property name="whoami" value="apps"/>
> </ant>
> </target>
> </project>
>
The property element is embedded within the ant element. You are thus
specifying the value of the property whoami for the *spawned* ant. The
whoami property in the current execution is unaffected. Check it out by
putting an echo after the ant task.
Does anyone know if this would work:
<project name="fakebuild" default="wrapper" basedir=".">
<target name="wrapper">
<property name="whoami" value="apps"/>
<ant antfile="dummy.xml" target="build-deploy">
<property name="whoami" value="${whoami}"/>
</ant>
</target>
</project>
-- Don
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/