Java Mailing List Archive

http://www.ant-tasks.com/

Apache Ant Archive

» Ant Users List
» Ant Developers List
AW: AW: AW: while-like structure in Ant

AW: AW: AW: while-like structure in Ant

2007-08-01       - By Jan.Materne@(protected)

Never tried instantiating conditions from javascript ...
But basically these are java classes.

So instantiate and set configure it
   myhttp = new Http();
   myhttp.setUrl("a url adress");
Maybe we could set a project instance or something like that.
Let's have a look at the sources [1,2] - yes. Http extends ProjectComponent.
So set the project reference so that Http could access properties and the
logger system.
   myhttp.setProject( self.getProject() );
Then use the condition [3]
   if (myhttp.eval()) {...



I havent tested these lines, so maybe you have to tweak javascript a little bit.


Jan


[1] http://svn.apache.org/repos/asf/ant/core/trunk/src/main/org/apache/tools
/ant/taskdefs/condition/Http.java
[2] http://svn.apache.org/repos/asf/ant/core/trunk/src/main/org/apache/tools
/ant/ProjectComponent.java
[3] http://svn.apache.org/repos/asf/ant/core/trunk/src/main/org/apache/tools
/ant/taskdefs/condition/Condition.java




>-----Urspr?ngliche Nachricht-----
>Von: Emir Mahmut BAHSI [mailto:embahsi@(protected)]
>Gesendet: Dienstag, 31. Juli 2007 19:35
>An: Ant Users List
>Betreff: Re: AW: AW: while-like structure in Ant
>
>Thanks for the information Jan. I am using both 'http'
>condition and 'get' task in my problem. I really want to know
>how can I create an 'http' condition in the javascript code below?
>
>>>myhttp = project.createTask("http");
>>>myhttp.setUrl("a url address");
>
>In the code above createTask is not appropriate I think since
>'http' is not a task. But how could I correct it? Any suggestion?
>
>Emir
>
>Jan.Materne@(protected) wrote: A condition is a different
>thing than a task
>- a condition checks something
>- a task does something.
>Of course an implementing class maybe can do both ( ).
>
>For HTTP there are two different implementations:
>- condition
>- task
>(- http AntLib http://ant.apache.org/antlibs/sandbox.html )
>
>
>Jan
>
>
>>-----Urspr?ngliche Nachricht-----
>>Von: Emir Mahmut BAHSI [mailto:embahsi@(protected)]
>>Gesendet: Montag, 30. Juli 2007 23:34
>>An: Ant Users List
>>Betreff: Re: AW: while-like structure in Ant
>>
>>It is a good point! Http task is one of the core conditions
>>that can be used as a nested element in condition task.
>>FYI: http://ant.apache.org/manual/CoreTasks/conditions.html
>>
>>However I do not know why it is not listed in the manual as a
>>core task :) May be it is because of being a nested element
>>for condition task (core condition).
>>
>>Emir M Bahsi
>>
>>Jan.Materne@(protected) wrote: Which  task? Ant Core doesnt
>>have one.
>>
>>Jan
>>
>>>-----Urspr?ngliche Nachricht-----
>>>Von: Emir Mahmut BAHSI [mailto:embahsi@(protected)]
>>>Gesendet: Sonntag, 29. Juli 2007 00:27
>>>An: Ant Users List
>>>Betreff: RE: while-like structure in Ant
>>>
>>>Sorry everybody for the late replay. I am trying to implement
>>>that while structure as I explained before. I am using
>>>javascript for that. However, I can not create a http task in
>>>javascript code. That part of the code is:
>>>
>>>myhttp = project.createTask("http");
>>>myhttp.setUrl("a url address");
>>>
>>>The error is: javax.script.ScriptException:
>>>sun.org.mozilla.javascript.internal.EcmaError: TypeError:
>>>Cannot call method "setUrl" of null <#5> in
>>> at line number 5
>>>
>>>Any help is appreciated. Thanks in advance.
>>>
>>>Emir Mahmut Bahsi
>>>
>>>
>>>
>>>
>>>
>>>
>>>"Rebhan, Gilbert"  wrote:
>>>-----Original Message-----
>>>From: Xavier Hanin [mailto:xavier.hanin@(protected)]
>>>Sent: Thursday, May 10, 2007 9:17 AM
>>>To: Ant Users List
>>>Subject: Re: while-like structure in Ant
>>>
>>>On 5/10/07, Emir Mahmut BAHSI  wrote:
>>>>
>>>> Hi all,
>>>> I have been working on conditional structures and loop
>structures on
>>>> existing workflow managers for a long time. For this purpose I have
>>>> implemented two simple examples for if-type and switch-type cases
>>>(examples
>>>> are attached). In these examples my program is simply downloading a
>>>file. If
>>>> that file does not exist in the first web address it tries another
>>>address.
>>>> However, I could not implement a loop structure for that.
>>In the loop
>>>case
>>>> the program should try the same address until the file exists.
>>>Actually I
>>>> know this is not a reasonable and useful scenario but I
>just want to
>>>show
>>>> whether a conditional-loop scenario can be implemented in Ant.
>>>>
>>>> Can u suggest me anything to implement that example. Any help is
>>>> appreciated.
>>>
>>>/*
>>>The ant-contrib project is providing conditional tasks which
>may help,
>>>but
>>>if you want to have your own syntax and the very specific url
>>>availability
>>>as a condition (like you wrote), maybe using a script (using
>scriptdef
>>>for
>>>example) would be a good fit.
>>>*/
>>>
>>>+1
>>>
>>>i would go via  and a scripting language running in
>>>BSF
>>>(JRuby, Groovy, Beanshell ... )
>>>
>>>or use the AntBuilder@(protected)
>>>
>>>see >>>http://groovy.codehaus.org/
>>>http://www.bytemycode.com/snippets/snippet/475/
>>>
>>>Regards, Gilbert
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: user-unsubscribe@(protected)
>>>For additional commands, e-mail: user-help@(protected)
>>>
>>>
>>>
>>>
>>>---------------------------------
>>>Take the Internet to Go: Yahoo!Go puts the Internet in your
>>>pocket: mail, news, photos & more.
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@(protected)
>>For additional commands, e-mail: user-help@(protected)
>>
>>
>>
>>
>>---------------------------------
>>Building a website is a piece of cake.
>>Yahoo! Small Business gives you all the tools to get online.
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@(protected)
>For additional commands, e-mail: user-help@(protected)
>
>
>
>
>---------------------------------
>Pinpoint customers who are looking for what you sell.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)


©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.