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 <bartolole...@gmail.com>:

> 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.
>

Reply via email to