thank you for the fast answer... yes with "this." it works

2016-03-11 13:36 GMT+01:00 Cédric Champeau [via Groovy] <[hidden email]>:
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]>:
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 [hidden email]
To unsubscribe from Groovy, click here.
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: Re: problem accessing class method from FileTreeBuilder in a closure
Sent from the Groovy Users mailing list archive at Nabble.com.