ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 32041] - want to remember a value set within a task next time the task is called
Date Wed, 03 Nov 2004 20:52:38 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=32041>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=32041

want to remember a value set within a task next time the task is called





------- Additional Comments From benjamin@yangtemko.com  2004-11-03 20:52 -------
Let me try to show you what I mean.  Here's a simplified example:


======================
[basebuild.xml]
...
<property name="default_rhost" value="192.168.1.1"/>
...
  <target name="remote_deploy">
    <input message="Enter remote server [${default_rhost}]: "
           addproperty="rd_rhost"
           defaultvalue="${default_rhost}"/>
    <property name="default_rhost" value="${rd_rhost}">
    <scp task here using user-supplied hostname in "rd_host">
  </target>
======================


======================
[projectbuild.xml]

  <import file="basebuild.xml"/>

  <target name="remote_deploy" description="scp files">
    <antcall target="basebuild.remote_deploy">
        <params to specify first set of files fo here>
    </antcall>
    <antcall target="basebuild.remote_deploy">
        <params to specify next set of files go here>
    </antcall>
    <ant call and so on>
  </target>
======================

OK, from the top : 

I have basebuild, which is included in projectbuild.  The basebuild file defines
the remote_deploy task which projectbuild uses to deploy several different sets
of files remotely, possible to one or more servers, possibly not, it is not
known until I'm ready for deployment.

1) default_rhost gets set to 192.168.1.1
2) antcall to basebuild.remote_deploy occurs, the user is asked for input
3) user gives 192.168.23.24
4) I set the "default_rhost" variable to the user supplied value, which works
    as long as this Target is active.
5) first set of files is deployed to 192.168.23.24
6) basebuild.remote_deploy Target ends, *** "default_rhost" resets to
   "192.168.1.1" *** 
7) second antcall to remote_deploy occurs, the user is asked for input, but the
   "default_rhost" variable doesn't remember what the user put in last time, 
   even though I attempted to set its value within the Target.


I've tried this in several different ways and its always the same.

Changing the value of a property in the scope of a single Target execution works
fine with ant-contrib's Variable, but once the Target has completed, it ** does
not remember ** the last value it had.  If I call that Target again and attempt
to access either an ant-contrib Variable or a Property which only has scope
within that Target (i.e. it has no <property> task outside of the Target to
which it is assigned a value), it is empty.  There is no memory of its last value.

Why is this useful?  In our case, because we want to be able to have the user
re-use a given value several times in a row, rather then potentially mis-typing
an ip address and having files get deployed to the wrong place.  The user gives
a value once (or, in our case, picks a value from a list), and then can re-use
it until he needs to give a different value.  In the interim, *** between Target
calls*, and remembers the last thing the user gave as input.

I hope this is clearer?

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message