public interface SourceSetOutput extends FileCollection
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 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:
apply plugin: '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 { 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()
FileCollection.AntType
修飾子とタイプ | メソッドと説明 |
---|---|
void |
dir(Map<String,Object> options,
Object dir)
Registers an extra output dir and the builtBy information.
|
void |
dir(Object dir)
Registers an extra output dir.
|
File |
getClassesDir()
Returns the directory to assemble the compiled classes into.
|
FileCollection |
getDirs()
Returns all dirs registered with #dir method.
|
File |
getResourcesDir()
Returns the output directory for resources
See example at
SourceSetOutput |
void |
setClassesDir(Object classesDir)
Sets the directory to assemble the compiled classes into.
|
void |
setResourcesDir(Object resourcesDir)
Sets the output directory for resources
See example at
SourceSetOutput |
add, addToAntBuilder, addToAntBuilder, asType, contains, filter, filter, getAsFileTree, getAsPath, getFiles, getSingleFile, isEmpty, minus, plus, stopExecutionIfEmpty
forEach, iterator, spliterator
getBuildDependencies
File getClassesDir()
See example at SourceSetOutput
void setClassesDir(Object classesDir)
See example at SourceSetOutput
classesDir
- the classes dir. Should not be null.File getResourcesDir()
See example at SourceSetOutput
void setResourcesDir(Object resourcesDir)
See example at SourceSetOutput
resourcesDir
- the classes dir. Should not be null.void dir(Map<String,Object> options, Object dir)
See example at SourceSetOutput
options
- - use 'builtBy' key to configure the 'builtBy' task of the dirdir
- - will be resolved as Project.file(Object)
void dir(Object dir)
See example at SourceSetOutput
dir
- - will be resolved as Project.file(Object)
FileCollection getDirs()
Project.file(Object)
See example at SourceSetOutput