Hi Scot,

Thanks a lot for your reply.
What you mentioned as "ant xml task" means tasks without using 
ScriptTask, is it right ?

In fact, my project (not ant project!) uses the customized Ant, and in 
it, the Task inherited from ScriptTask has a great importance..

So, I try to describe the Ant scripts using Script Task as much as 
possible (;_;)

I hope you will have much free time this weekend, and you will have some 
interest on this ! :-)

Best Regards,
trad-ex

>I've never used the <script> task...so I really don't have an answer for 
>you...
>
>I do have a question...is there a reason you are using script versus ant 
>xml tasks?  I'm guessing its just to see how things work?
>
>Sorry I don't have an answer :(  I am fairly slammed today at work...so 
>I don't have much time to look into this...I might have some free time 
>this weekend...no promises ;)
>
>Scot
>
>trad-ex wrote:
>> Hi Scot,
>> Hi folks,
>>
>> Sorry for my late response & poor English.
>>
>> I try to organize the discussion on this thread.
>> As originally questions by other person, how can he pass values from a 
>> script into a target in spite of the immutablity of properties in Ant ?
>> A part of his script is below:
>>
>> <target name="test">
>>   <script language="javascript"><![CDATA[
>>     project = self.getProject();
>>     echo = project.createTask("echo");
>>     project.setProperty("theVal", "foo");
>>     echo.setMessage(project.getProperty("theVal"));
>>     echo.perform();
>>     echoval.execute();
>>     project.setProperty("theVal", "bar");
>>     echo.setMessage(project.getProperty("theVal"));
>>     echo.perform();
>>     echoval.execute();
>>   ]]></script>
>> </target>
>> <target name="echoval">
>>    <echo>${theVal}</echo>
>> </target>
>>
>> This script produces the following output.
>>
>>    test:
>>         [echo] foo
>>         [echo] foo
>>         [echo] bar
>>         [echo] foo ( -> bar expected )
>>
>> So, because the way of getting rid of immutability is using VariableTask 
>> in Ant-contrib, I tried to change his script above like this below:
>>
>>   <script language="javascript"><![CDATA[
>>     project = self.getProject();
>>     echo = project.createTask("echo");
>>     variable = project.createTask("var");
>>     variable.setName("theVal");
>>     variable.setValue("foo");
>>     variable.execute();
>>     echo.setMessage(project.getProperty("theVal"));
>>     echo.perform();
>>     echoval.execute();
>>     variable.setName("theVal");
>>     variable.setValue("bar");
>>     variable.execute();
>>     echo.setMessage(project.getProperty("theVal"));
>>     echo.perform();
>>     echoval.execute();
>>   ]]></script>
>>
>> But, this script replicated the same result
>>
>>         [echo] foo
>>         [echo] foo
>>         [echo] bar
>>         [echo] foo ( -> bar expected )
>>
>> So I consulted the javadoc of Ant, I found that org.apache.tools.ant.
>> Project#setProperty can overwrite the given property!
>>
>> My questions are:
>> 1. Why couldn't the first script overwrite the value of property ?
>>    It's not because of immutability, IMHO.
>> 2. What's wrong with my ( second ) script ?
>> 3. Without using MacrodefTask, can this issue be solved just by 
>> ScriptTask ?
>>
>> Sorry for my tedious explanation.
>>
>> Best Regards,
>> trad-ex
>>
>>
>>
>>   
>>> To be honest, I've never used the <script> feature of ant.  Sorry, I 
>>> think I misunderstood your question...  More to the point...it looks 
>>> like I didn't read the question correctly...
>>>
>>> Sorry 'bout that :)
>>>
>>> Scot
>>>
>>> trad-ex wrote:
>>>     
>>>> Hi Scot,
>>>>
>>>> Thanks a lot for your reply.
>>>> Yes, I've already known that behavior of "Variable" Task.
>>>> What I would like to know is the proper coding in Script Task by using 
>>>> Javascript.
>>>>
>>>> I wonder my conding doesn't make sense ?
>>>>
>>>> Best Regards,
>>>> trad-ex
>>>>
>>>>   
>>>>       
>>>>> I think the idea here is to use <var> from ant contrib.  It definitely 
>>>>> works and allows one to reset properties...
>>>>>
>>>>> For instance:
>>>>>
>>>>> <project  name = "example">
>>>>>    <taskdef  resource = "net/sf/antcontrib/antlib.xml"/>
>>>>>
>>>>>    <var name = "my-var" value = "foo"/>
>>>>>    <echo message = "my-var = ${my-var}"/>
>>>>>
>>>>>    <var name = "my-var" value = "bar"/>
>>>>>    <echo message = "my-var = ${my-var}"/>
>>>>>
>>>>>    <var name = "my-var" value = "alpha"/>
>>>>>    <echo message = "my-var = ${my-var}"/>
>>>>> </project>
>>>>>
>>>>> Will yield:
>>>>>
>>>>>     [echo] my-var = foo
>>>>>     [echo] my-var = bar
>>>>>     [echo] my-var = alpha
>>>>>
>>>>> Above, the variable is being changed...
>>>>>
>>>>> trad-ex wrote:
>>>>>     
>>>>>         
>>>>>> Hi Steve,
>>>>>>
>>>>>> I tried to use "Variables" Task in ant-contrib, but it replicate the 
>>>>>> same result as Dick did.
>>>>>> My build.xml is:
>>>>>>
>>>>>> <?xml version="1.0" ?>
>>>>>> <project name="build" basedir="." default="test">
>>>>>> <taskdef resource="net/sf/antcontrib/antlib.xml"/>
>>>>>>   <target name="test">
>>>>>>      <script language="javascript">
>>>>>>         <![CDATA[
>>>>>>           project = self.getProject();
>>>>>>           echo = project.createTask("echo");
>>>>>>           variable = project.createTask("var");
>>>>>>           variable.setName("theVal");
>>>>>>           variable.setValue("foo");
>>>>>>           variable.execute();
>>>>>>           echo.setMessage(project.getProperty("theVal"));
>>>>>>           echo.perform();
>>>>>>           echoval.execute();
>>>>>>           variable.setName("theVal");
>>>>>>           variable.setValue("bar");
>>>>>>           variable.execute();
>>>>>>           echo.setMessage(project.getProperty("theVal"));
>>>>>>           echo.perform();
>>>>>>           echoval.execute();
>>>>>>         ]]>
>>>>>>       </script>
>>>>>>    </target>
>>>>>>    <target name="echoval">
>>>>>>       <echo>${theVal}</echo>
>>>>>>    </target>
>>>>>> </project>
>>>>>>
>>>>>> The Result is:
>>>>>>
>>>>>> c:\>ant -v
>>>>>> Apache Ant version 1.6.2 compiled on July 16 2004
>>>>>> Buildfile: build.xml
>>>>>> Detected Java version: 1.4 in: C:\j2sdk1.4.1_07\jre
>>>>>> Detected OS: Windows XP
>>>>>> parsing buildfile C:\build.xml with URI = file:///C:/build.xml
>>>>>> Project base dir set to: C:\
>>>>>> parsing buildfile 
>>>>>> jar:file:/C:/apache-ant-1.6.2/lib/ant-contrib.jar!/net/sf/antcontrib/
>>>>>> antlib.xml 
>>>>>> with URI = 
>>>>>> jar:file:/C:/apache-ant-1.6.2/lib/ant-contrib.jar!/net/sf/antcontrib/
>>>>>> antlib.xml
>>>>>> Build sequence for target `test' is [test]
>>>>>> Complete build sequence is [test, echoval, ]
>>>>>>
>>>>>> test:
>>>>>>      [echo] foo
>>>>>>      [echo] foo
>>>>>>      [echo] bar
>>>>>>      [echo] foo
>>>>>>
>>>>>> BUILD SUCCESSFUL
>>>>>> Total time: 0 seconds
>>>>>> c:\>
>>>>>>
>>>>>> Why ?
>>>>>> What's wrong with my description about "Variable" task ?
>>>>>> Any comments will be very appreciated.
>>>>>>
>>>>>> Best Regards,
>>>>>> trad-ex
>>>>>>
>>>>>>   
>>>>>>       
>>>>>>           
>>>>>>> Dick, Brian E. wrote:
>>>>>>>     
>>>>>>>         
>>>>>>>             
>>>>>>>> I have just a day to get this working. These are production machines,
>>>>>>>>  so
>>>>>>>> I can't deploy anything to them.
>>>>>>>>
>>>>>>>> I'm using sshexec to remotely ping from a unix host and using rcmd to
>>>>>>>> remotely ping from a windows host. I redirect the output from these
>>>>>>>> tasks to a file and then use loadfile with a filterchain to load the
>>>>>>>> ipaddress into a property.
>>>>>>>>
>>>>>>>> This works all fine and dandy except I need to do it in a loop, so 
>>>>>>>> that
>>>>>>>> led me to the script task. But I was having problems getting the
>>>>>>>> ipaddress set by loadfile back to the script. I didn't want to create
>>>>>>>> 20x100 properties, but if that's what it takes, so be it.
>>>>>>>>
>>>>>>>>       
>>>>>>>>           
>>>>>>>>               
>>>>>>> In that case, grab the <var> task from ant-contrib, which can be used 
>>>>>>> to 
>>>>>>> erase a property before you reuse it.
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>>>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>>>>>     
>>>>>>>         
>>>>>>>             
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>>>>
>>>>>>
>>>>>>   
>>>>>>       
>>>>>>           
>>>>> -- 
>>>>> Scot P. Floess
>>>>> 27 Lake Royale
>>>>> Louisburg, NC  27549
>>>>>
>>>>> 252-478-8087 (Home)
>>>>> 919-754-4592 (Work)
>>>>>
>>>>> Chief Architect JPlate  http://sourceforge.net/projects/jplate
>>>>> Chief Architect JavaPIM http://sourceforge.net/projects/javapim
>>>>>     
>>>>>         
>>>>   
>>>>       
>>> -- 
>>> Scot P. Floess
>>> 27 Lake Royale
>>> Louisburg, NC  27549
>>>
>>> 252-478-8087 (Home)
>>> 919-754-4592 (Work)
>>>
>>> Chief Architect JPlate  http://sourceforge.net/projects/jplate
>>> Chief Architect JavaPIM http://sourceforge.net/projects/javapim
>>>
>>>
>>>
>>> ---html-part included links-------
>>> mailto:[EMAIL PROTECTED]
>>> mailto:[EMAIL PROTECTED]
>>>     
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>   
>
>-- 
>Scot P. Floess
>27 Lake Royale
>Louisburg, NC  27549
>
>252-478-8087 (Home)
>919-754-4592 (Work)
>
>Chief Architect JPlate  http://sourceforge.net/projects/jplate
>Chief Architect JavaPIM http://sourceforge.net/projects/javapim


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to