Package org.gradle.api.tasks

## Interface SourceSetOutput

- All Superinterfaces:
    `AntBuilderAware`, `Buildable`, `FileCollection`, `Iterable<File>`

      public interface SourceSetOutput
      extends FileCollection

  A collection of all output directories (compiled classes, processed resources, etc.) - notice that `SourceSetOutput` extends `FileCollection`.

  Provides output information of the source set. Allows configuring the default output dirs and specify additional output dirs.

       plugins {
           id 'java'
       }

       sourceSets {
         main {
           //if you truly want to override the defaults:
           output.resourcesDir = file('out/bin')
           // Compiled Java classes should use this directory
           java.destinationDirectory.set(file('out/bin'))
         }
       }

  Working with generated resources.

  In general, we recommend generating resources into folders different than the regular resourcesDir and classesDirs. Usually, it makes the build easier to understand and maintain. Also it gives some additional benefits because other Gradle plugins can take advantage of the output dirs 'registered' in the SourceSet.output. For example: Java plugin will use those dirs in calculating class paths and for jarring the content; IDEA and Eclipse plugins will put those folders on relevant classpath.

  An example how to work with generated resources:

       plugins {
           id 'java'
       }

       def generatedResources = "$buildDir/generated-resources/main"

       sourceSets {
         main {
           //let's register an output folder on the main SourceSet:
           output.dir(generatedResources, builtBy: 'generateMyResources')
           //it is now a part of the 'main' classpath and will be a part of the jar
         }
       }

       //a task that generates the resources:
       task generateMyResources {
         outputs.dir generatedResources
         doLast {
           def generated = new File(generatedResources, "myGeneratedResource.properties")
           generated.text = "message=Stay happy!"
         }
       }

       //Java plugin task 'classes' and 'testClasses' will automatically depend on relevant tasks registered with 'builtBy'

       //Eclipse/IDEA plugins will automatically depend on 'generateMyResources'
       //because the output dir was registered with 'builtBy' information
       apply plugin: 'idea'; apply plugin: 'eclipse'

  Find more information in `dir(java.util.Map, Object)` and `getDirs()`

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.gradle.api.file.FileCollection

      `FileCollection.AntType`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `dir​(Object dir)` | Registers an extra output dir.
    `void` | `dir​(Map<String,​Object> options, Object dir)` | Registers an extra output dir and the builtBy information.
    `FileCollection` | `getClassesDirs()` | Returns the directories containing compiled classes.
    `FileCollection` | `getDirs()` | Returns all dirs registered with #dir method.
    `FileCollection` | `getGeneratedSourcesDirs()` | Returns the directories containing generated source files (e.g.
    `File` | `getResourcesDir()` | Returns the output directory for resources
    `void` | `setResourcesDir​(File resourcesDir)` | Sets the output directory for resources
    `void` | `setResourcesDir​(Object resourcesDir)` | Sets the output directory for resources

    - ### Methods inherited from interface org.gradle.api.Buildable

      `getBuildDependencies`

    - ### Methods inherited from interface org.gradle.api.file.FileCollection

      `addToAntBuilder, addToAntBuilder, contains, filter, filter, getAsFileTree, getAsPath, getElements, getFiles, getSingleFile, isEmpty, minus, plus`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, iterator, spliterator`

- - ### Method Detail

    - #### getClassesDirs

          FileCollection getClassesDirs()

      Returns the directories containing compiled classes.
      Returns:
        The classes directories. Never returns null.
      Since:
        4.0

    - #### getResourcesDir

          @Nullable
          File getResourcesDir()

      Returns the output directory for resources

      See example at `SourceSetOutput`

      Returns:
        The dir resources are copied to.

    - #### setResourcesDir

          void setResourcesDir​(File resourcesDir)

      Sets the output directory for resources

      See example at `SourceSetOutput`

      Parameters:
        `resourcesDir` - the classes dir. Should not be null.
      Since:
        4.0

    - #### setResourcesDir

          void setResourcesDir​(Object resourcesDir)

      Sets the output directory for resources

      See example at `SourceSetOutput`

      Parameters:
        `resourcesDir` - the classes dir. Should not be null.

    - #### dir

          void dir​(Map<String,​Object> options,
                   Object dir)

      Registers an extra output dir and the builtBy information. Useful for generated resources.

      See example at `SourceSetOutput`

      Parameters:
        `options` - - use 'builtBy' key to configure the 'builtBy' task of the dir
        `dir` - - will be resolved as `Project.file(Object)`

    - #### dir

          void dir​(Object dir)

      Registers an extra output dir. Useful for generated resources.

      See example at `SourceSetOutput`

      Parameters:
        `dir` - - will be resolved as `Project.file(Object)`

    - #### getDirs

          FileCollection getDirs()

      Returns all dirs registered with #dir method. Each file is resolved as `Project.file(Object)`

      See example at `SourceSetOutput`

      Returns:
        a new instance of registered dirs with resolved files

    - #### getGeneratedSourcesDirs

          FileCollection getGeneratedSourcesDirs()

      Returns the directories containing generated source files (e.g. by annotation processors during compilation).
      Returns:
        The generated sources directories. Never returns null.
      Since:
        5.2