Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD

## org.gradle.api.tasks
[Java] Interface SourceSetOutput

    org.gradle.api.tasks.AntBuilderAware
      org.gradle.api.file.FileCollection
          org.gradle.api.tasks.SourceSetOutput
              org.gradle.api.Buildable

All Superinterfaces:
  AntBuilderAware, FileCollection, Buildable

    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.

     apply plugin: 'java'

     sourceSets {
       main {
         //if you truly want to override the defaults:
         output.resourcesDir = 'out/res'
         output.classesDir   = 'out/bin'
       }
     }

Working with generated resources.

In general, we recommend generating resources into folders different than the regular resourcesDir and classesDir. 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 classpaths and for jarring the content; idea and eclipse plugins will put those folders on relevant classpath.

An example how to work with generated resources:

     apply plugin: 'java'

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

     sourceSets {
       main {
         //let's register an output folder on the main SourceSet:
         output.dir(generatedResources, buildBy: '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 {
       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 by 'buildBy'

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

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

Method Summary
`void` | `dir(java.util.Map options, java.lang.Object dir)` Registers an extra output dir and the buildBy information.
`void` | `dir(java.lang.Object dir)` Registers an extra output dir.
`java.io.File` | `getClassesDir()` Returns the directory to assemble the compiled classes into.
`FileCollection` | `getDirs()` Returns all dirs registered with with #dir method.
`java.io.File` | `getResourcesDir()` Returns the output directory for resources See example at SourceSetOutput
`void` | `setClassesDir(java.lang.Object classesDir)` Sets the directory to assemble the compiled classes into.
`void` | `setResourcesDir(java.lang.Object resourcesDir)` Sets the output directory for resources See example at SourceSetOutput

Methods inherited from interface FileCollection
add, addToAntBuilder, addToAntBuilder, asType, contains, filter, filter, getAsFileTree, getAsPath, getFiles, getSingleFile, isEmpty, minus, plus, stopExecutionIfEmpty

Methods inherited from interface AntBuilderAware
addToAntBuilder

Methods inherited from interface java.lang.Iterable
java.lang.Iterable#iterator()

Methods inherited from interface Buildable
getBuildDependencies

Method Detail

### dir

    public void dir(java.util.Map options, java.lang.Object dir)

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

  See example at SourceSetOutput

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

### dir

    public void dir(java.lang.Object dir)

  Registers an extra output dir. Useful for generated resources.

  See example at SourceSetOutput

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

### getClassesDir

    public java.io.File getClassesDir()

  Returns the directory to assemble the compiled classes into.

  See example at SourceSetOutput

  Returns:
    The classes dir. Never returns null.

### getDirs

    public FileCollection getDirs()

  Returns all dirs registered with with #dir method. Each file is resolved as Project.file

  See example at SourceSetOutput

  Returns:
    a new instance of registered dirs with resolved files

### getResourcesDir

    public java.io.File getResourcesDir()

  Returns the output directory for resources

  See example at SourceSetOutput

  Returns:
    The dir resources are copied to.

### setClassesDir

    public void setClassesDir(java.lang.Object classesDir)

  Sets the directory to assemble the compiled classes into.

  See example at SourceSetOutput

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

### setResourcesDir

    public void setResourcesDir(java.lang.Object resourcesDir)

  Sets the output directory for resources

  See example at SourceSetOutput

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

Groovy Documentation