Schnittstelle SourceSetOutput
- Alle Superschnittstellen:
AntBuilderAware,Buildable,FileCollection,Iterable<File>
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 generateResourcesTask = tasks.register("generate-resources", GenerateResourcesTask) {
resourcesDir.set(layout.buildDirectory.dir("generated-resources/main"))
}
// Include all outputs of the `generate-resources` task as outputs of the main sourceSet.
sourceSets {
main {
output.dir(generateResourcesTask)
}
}
abstract class GenerateResourcesTask extends DefaultTask {
@OutputDirectory
abstract DirectoryProperty getResourcesDir()
@TaskAction
def generateResources() {
def generated = resourcesDir.file("myGeneratedResource.properties").get().asFile
generated.text = "message=Stay happy!"
}
}
Find more information in dir(Object) and getDirs()-
Verschachtelte Klassen - Übersicht
Von Schnittstelle geerbte verschachtelte Klassen/Schnittstellen org.gradle.api.file.FileCollection
FileCollection.AntType -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidRegisters an extra output dir.voidRegisters an extra output dir and the builtBy information.Returns the directories containing compiled classes.getDirs()Returns all dirs registered with #dir method.Returns the directories containing generated source files (e.g. by annotation processors during compilation).Returns the output directory for resourcesvoidsetResourcesDir(File resourcesDir) Sets the output directory for resourcesvoidsetResourcesDir(Object resourcesDir) Sets the output directory for resourcesVon Schnittstelle geerbte Methoden org.gradle.api.Buildable
getBuildDependenciesVon Schnittstelle geerbte Methoden org.gradle.api.file.FileCollection
addToAntBuilder, addToAntBuilder, contains, filter, filter, getAsFileTree, getAsPath, getElements, getFiles, getSingleFile, isEmpty, minus, plusVon Schnittstelle geerbte Methoden java.lang.Iterable
forEach, iterator, spliterator
-
Methodendetails
-
getClassesDirs
FileCollection getClassesDirs()Returns the directories containing compiled classes.- Gibt zurück:
- The classes directories. This value may safely be cast to a
ConfigurableFileCollection. - Seit:
- 4.0
-
getResourcesDir
Returns the output directory for resourcesSee example at
SourceSetOutput- Gibt zurück:
- The dir resources are copied to.
-
setResourcesDir
Sets the output directory for resourcesSee example at
SourceSetOutput- Parameter:
resourcesDir- the resources dir. Should not be null.- Seit:
- 4.0
-
setResourcesDir
Sets the output directory for resourcesSee example at
SourceSetOutput- Parameter:
resourcesDir- the resources dir. Should not be null.
-
dir
Registers an extra output dir and the builtBy information. Useful for generated resources.See example at
SourceSetOutput- Parameter:
options- - use 'builtBy' key to configure the 'builtBy' task of the dirdir- - will be resolved asProject.file(Object)
-
dir
Registers an extra output dir. Useful for generated resources.See example at
SourceSetOutput- Parameter:
dir- - will be resolved asProject.file(Object)
-
getDirs
FileCollection getDirs()Returns all dirs registered with #dir method. Each file is resolved asProject.file(Object)See example at
SourceSetOutput- Gibt zurück:
- 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).- Gibt zurück:
- The generated sources directories. Never returns null.
- Seit:
- 5.2
-