Package: groovy.util

## [Groovy] Class FileTreeBuilder

- groovy.util.FileTreeBuilder

- A builder dedicated at generating a file directory structure from a specification. For example, imagine that you want to create the following tree:

       src/
        |--- main
        |     |--- groovy
        |            |--- Foo.groovy
        |--- test
              |--- groovy
                     |--- FooTest.groovy

  Then you can create the structure using:

           def tree = new FileTreeBuilder()
           tree.dir('src') {
              dir('main') {
                 dir('groovy') {
                    file('Foo.groovy', 'println "Hello"')
                 }
              }
              dir('test') {
                 dir('groovy') {
                    file('FooTest.groovy', 'class FooTest extends GroovyTestCase {}')
                 }
              }
           }

  or with this shorthand syntax:

           def tree = new FileTreeBuilder()
           tree.src {
              main {
                 groovy {
                    'Foo.groovy'('println "Hello"')
                 }
              }
              test {
                 groovy {
                    'FooTest.groovy'('class FooTest extends GroovyTestCase {}')
                 }
              }
           }

  Since:
    2.4.2

- - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `File` | `baseDir`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `FileTreeBuilder (File baseDir = new File('.')`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `File` | `call(Closure spec)`
    `` | `File` | `dir(String name)` Creates a new empty directory
    `` | `File` | `dir(String name, Closure cl)` Creates a new directory and allows to specify a subdirectory structure using the closure as a specification
    `` | `File` | `file(String name, CharSequence contents)` Creates a file with the specified name and the text contents using the system default encoding.
    `` | `File` | `file(String name, byte[] contents)` Creates a file with the specified name and the specified binary contents
    `` | `File` | `file(String name, File source)` Creates a file with the specified name and the contents from the source file (copy).
    `` | `File` | `file(String name, Closure spec)` Creates a new file in the current directory, whose contents is going to be generated in the closure.
    `` | `def` | `methodMissing(String name, def args)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, toString, hashCode, getClass, notify, notifyAll, wait, wait, wait`

- - ### Property Detail

    - #### File baseDir

  - ### Constructor Detail

    - #### FileTreeBuilder(File baseDir = new File('.')

  - ### Method Detail

    - #### File call(@DelegatesTo(value = FileTreeBuilder, strategy = Closure.DELEGATE_FIRST) Closure spec)

    - #### File dir(String name)

      Creates a new empty directory

      Parameters:
        `name` - the name of the directory to create
      Returns:
        the created directory

    - #### File dir(String name, @DelegatesTo(value = FileTreeBuilder, strategy = Closure.DELEGATE_FIRST) Closure cl)

      Creates a new directory and allows to specify a subdirectory structure using the closure as a specification

      Parameters:
        `name` - name of the directory to be created
        `cl` - specification of the subdirectory structure
      Returns:
        the created directory

    - #### File file(String name, CharSequence contents)

      Creates a file with the specified name and the text contents using the system default encoding.

      Parameters:
        `name` - name of the file to be created
        `contents` - the contents of the file, written using the system default encoding
      Returns:
        the file being created

    - #### File file(String name, byte[] contents)

      Creates a file with the specified name and the specified binary contents

      Parameters:
        `name` - name of the file to be created
        `contents` - the contents of the file
      Returns:
        the file being created

    - #### File file(String name, File source)

      Creates a file with the specified name and the contents from the source file (copy).

      Parameters:
        `name` - name of the file to be created
        `contents` - the contents of the file
      Returns:
        the file being created

    - #### File file(String name, @DelegatesTo(value = File, strategy = Closure.DELEGATE_FIRST) Closure spec)

      Creates a new file in the current directory, whose contents is going to be generated in the closure. The delegate of the closure is the file being created.

      Parameters:
        `name` - name of the file to create
        `spec` - closure for generating the file contents
      Returns:
        the created file

    - #### def methodMissing(String name, def args)