Movatterモバイル変換


[0]ホーム

URL:


SourceSetOutput

Table of Contents

Properties
Methods
Script blocks
Property details
Method details
API Documentation:SourceSetOutput

A collection of all output directories (compiled classes, processed resources, etc.) - notice thatSourceSetOutput extendsFileCollection.

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.outputDir = 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 benefitsbecause 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' informationapply plugin:'idea'; apply plugin:'eclipse'

Find more information inSourceSetOutput.dir(java.util.Map, java.lang.Object) andSourceSetOutput.getDirs()

Properties

PropertyDescription
classesDirs

The directories containing compiled classes.

resourcesDir

The output directory for resources

Methods

MethodDescription
dir(dir)

Registers an extra output dir. Useful for generated resources.

dir(options, dir)

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

getDirs()

Returns all dirs registered with #dir method.Each file is resolved asProject.file(java.lang.Object)

Script blocks

No script blocks

Property details

FileCollectionclassesDirs (read-only)

The directories containing compiled classes.

Default withjava plugin:
a file collection of each${project.buildDir}/classes/${sourceDirectorySet.name}/${sourceSet.name}

FileresourcesDir

The output directory for resources

See example atSourceSetOutput

Default withjava plugin:
${project.buildDir}/classes/${sourceSet.name}

Method details

voiddir(Object dir)

Registers an extra output dir. Useful for generated resources.

See example atSourceSetOutput

voiddir(Map<String,Object> options,Object dir)

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

See example atSourceSetOutput

Returns all dirs registered with #dir method.Each file is resolved asProject.file(java.lang.Object)

See example atSourceSetOutput


[8]ページ先頭

©2009-2025 Movatter.jp