For AI agents: the documentation index is at https://docs.gradle.org/llms.txt. Request any page with the header Accept: text/markdown to get Markdown. User manual pages are also available as Markdown by replacing .html with .md in the URL.

sourceSets

abstract fun sourceSets(closure: Closure): Any(source)

Configures the source sets of this project.

Return

NamedDomainObjectContainer

Since

7.1

Parameters

closure

The closure to execute.

See also


Configures the source sets of this project.

The given action is executed to configure the SourceSetContainer.

See the example below how org.gradle.api.tasks.SourceSet 'main' is accessed and how the org.gradle.api.file.SourceDirectorySet 'java' is configured to exclude some package from compilation.

plugins {
    id 'java'
}

sourceSets {
  main {
    java {
      exclude 'some/unwanted/package/**'
    }
  }
}

Since

9.3.0

Parameters

action

the configuration action