Re: problem accessing class method from FileTreeBuilder in a closure

2016-03-11 Thread bartoleo
thank you for the fast answer... yes with "this." it works

2016-03-11 13:36 GMT+01:00 Cédric Champeau [via Groovy] <
ml-node+s329449n5731841...@n5.nabble.com>:

> I noticed exactly this a few days ago. The builder interprets the call as
> internal. As a workaround you can prefix the class method with "this.":
> this.testData().
>
>
> 2016-03-11 13:29 GMT+01:00 bartoleo <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5731841&i=0>>:
>
>> Hi I'm using FileTreBuilder to create ten dirs with a file in it, the
>> content
>> is returned by a class method.
>>
>> Here is an example:
>>
>> class MyFileTreeBuilder {
>>
>>   static def testData(){
>> "my test data..."
>>   }
>>
>>   static void main(String[] args) {
>>
>> def tree = new FileTreeBuilder()
>> 10.times{index->
>>   tree.dir("tests/test${index}"){
>> file "test.txt", testData()
>>   }
>>   println(new File("tests/test${index}/test.txt").text)
>> }
>>
>>   }
>>
>> }
>>
>> It seems that FileTreeBuilder cannot find my class method if used in a
>> closure. (it works correctly if I remove the '10.times...'
>>
>> Could it be a bug?
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://groovy.329449.n5.nabble.com/problem-accessing-class-method-from-FileTreeBuilder-in-a-closure-tp5731840.html
>> Sent from the Groovy Users mailing list archive at Nabble.com.
>>
>
>
>
> --
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://groovy.329449.n5.nabble.com/problem-accessing-class-method-from-FileTreeBuilder-in-a-closure-tp5731840p5731841.html
> To start a new topic under Groovy Users, email
> ml-node+s329449n329450...@n5.nabble.com
> To unsubscribe from Groovy, click here
> <http://groovy.329449.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=329449&code=YmFydG9sb2xlbzc0QGdtYWlsLmNvbXwzMjk0NDl8LTEwMTExMjkyMzk=>
> .
> NAML
> <http://groovy.329449.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
Leo Bartoloni

---
Qualsiasi utilizzo non autorizzato del presente messaggio e dei suoi
allegati è vietato e potrebbe costituire reato.
Se lei avesse ricevuto erroneamente questo messaggio, Le saremmo grati se
provvedesse alla distruzione dello stesso
e degli eventuali allegati.
Opinioni, conclusioni o altre informazioni riportate nella e-mail, che non
siano relative alle attività e/o
alla missione aziendale. si intendono non attribuibili alla società stessa,
né la impegnano in alcun modo.




--
View this message in context: 
http://groovy.329449.n5.nabble.com/problem-accessing-class-method-from-FileTreeBuilder-in-a-closure-tp5731840p5731842.html
Sent from the Groovy Users mailing list archive at Nabble.com.

Re: problem accessing class method from FileTreeBuilder in a closure

2016-03-11 Thread Cédric Champeau
I noticed exactly this a few days ago. The builder interprets the call as
internal. As a workaround you can prefix the class method with "this.":
this.testData().


2016-03-11 13:29 GMT+01:00 bartoleo :

> Hi I'm using FileTreBuilder to create ten dirs with a file in it, the
> content
> is returned by a class method.
>
> Here is an example:
>
> class MyFileTreeBuilder {
>
>   static def testData(){
> "my test data..."
>   }
>
>   static void main(String[] args) {
>
> def tree = new FileTreeBuilder()
> 10.times{index->
>   tree.dir("tests/test${index}"){
> file "test.txt", testData()
>   }
>   println(new File("tests/test${index}/test.txt").text)
> }
>
>   }
>
> }
>
> It seems that FileTreeBuilder cannot find my class method if used in a
> closure. (it works correctly if I remove the '10.times...'
>
> Could it be a bug?
>
>
>
>
> --
> View this message in context:
> http://groovy.329449.n5.nabble.com/problem-accessing-class-method-from-FileTreeBuilder-in-a-closure-tp5731840.html
> Sent from the Groovy Users mailing list archive at Nabble.com.
>


problem accessing class method from FileTreeBuilder in a closure

2016-03-11 Thread bartoleo
Hi I'm using FileTreBuilder to create ten dirs with a file in it, the content
is returned by a class method.

Here is an example: 

class MyFileTreeBuilder {
  
  static def testData(){
"my test data..."
  }
  
  static void main(String[] args) {
  
def tree = new FileTreeBuilder()
10.times{index->
  tree.dir("tests/test${index}"){
file "test.txt", testData() 
  }
  println(new File("tests/test${index}/test.txt").text)
}

  }

}

It seems that FileTreeBuilder cannot find my class method if used in a
closure. (it works correctly if I remove the '10.times...'

Could it be a bug?




--
View this message in context: 
http://groovy.329449.n5.nabble.com/problem-accessing-class-method-from-FileTreeBuilder-in-a-closure-tp5731840.html
Sent from the Groovy Users mailing list archive at Nabble.com.