api / org.gradle.api.tasks / SourceTask

SourceTask

@NonNullApi open class SourceTask : ConventionTask, PatternFilterable

A SourceTask performs some operation on source files.

Constructors

<init>

SourceTask()

Functions

exclude

open fun exclude(vararg excludes: String): SourceTask
open fun exclude(excludes: MutableIterable<String>): SourceTask
open fun exclude(excludeSpec: Spec<FileTreeElement>): SourceTask
open fun exclude(excludeSpec: Closure<Any>): SourceTask

{@inheritDoc}

getExcludes

open fun getExcludes(): MutableSet<String>

{@inheritDoc}

getIncludes

open fun getIncludes(): MutableSet<String>

{@inheritDoc}

getSource

open fun getSource(): FileTree

Returns the source for this task, after the include and exclude patterns have been applied. Ignores source files which do not exist.

include

open fun include(vararg includes: String): SourceTask
open fun include(includes: MutableIterable<String>): SourceTask
open fun include(includeSpec: Spec<FileTreeElement>): SourceTask
open fun include(includeSpec: Closure<Any>): SourceTask

{@inheritDoc}

setExcludes

open fun setExcludes(excludes: MutableIterable<String>): SourceTask

{@inheritDoc}

setIncludes

open fun setIncludes(includes: MutableIterable<String>): SourceTask

{@inheritDoc}

setSource

open fun setSource(source: FileTree): Unit

Sets the source for this task.

open fun setSource(source: Any): Unit

Sets the source for this task. The given source object is evaluated as per org.gradle.api.Project#files(Object...).

source

open fun source(vararg sources: Any): SourceTask

Adds some source to this task. The given source objects will be evaluated as per org.gradle.api.Project#files(Object...).

Inheritors

AbstractCompile

abstract class AbstractCompile : SourceTask

The base class for all JVM-based language compilation tasks.

AntlrTask

open class AntlrTask : SourceTask

Generates parsers from Antlr grammars.

ApiJar

open class ApiJar : SourceTask

Assembles an "API Jar" containing only the members of a library's public API.

This task and the Jar it produces are designed primarily for internal use in support of Gradle's "compile avoidance" performance feature. The task is automatically included in the task graph for any JVM library that declares an api { ... } specification, and the resulting Jar will automatically be placed on the compile time classpath of projects that depend on the library in lieu of the library's complete so-called "Runtime Jar".

Swapping the API Jar in for the Runtime Jar at compile time is what makes "compile avoidance" possible: because the contents of the API Jar change only when actual API changes are made, the API Jar passes Gradle's up-to-date checks, even if the implementation in the Runtime Jar has changed. Ultimately, this means that projects depending on the library in question will need to recompile potentially far less often.

In order to ensure that API Jars change as infrequently as possible, this task and its supporting classes ensure that only actual public API members are included in the API Jar, and that the methods among those members are stripped of their implementation. Because the members included in API Jars exist only for compilation purposes, they need no actual implementation, and for this reason, all such methods throw UnsupportedOperationException in the unlikely event that they are present on the classpath and invoked at runtime.

The inputs to this task are Java class files which must be provided via org.gradle.api.tasks.TaskInputs.

Checkstyle

open class Checkstyle : SourceTask, VerificationTask, Reporting<CheckstyleReports>

Runs Checkstyle against some source files.

CodeNarc

open class CodeNarc : SourceTask, VerificationTask, Reporting<CodeNarcReports>

Runs CodeNarc against some source files.

CoffeeScriptCompile

open class CoffeeScriptCompile : SourceTask

FindBugs

open class FindBugs : SourceTask, VerificationTask, Reporting<FindBugsReports>

Analyzes code with FindBugs. See the FindBugs Manual for additional information on configuration options.

Groovydoc

open class Groovydoc : SourceTask

Generates HTML API documentation for Groovy source, and optionally, Java source.

This task uses Groovy's Groovydoc tool to generate the API documentation. Please note that the Groovydoc tool has some limitations at the moment. The version of the Groovydoc that is used, is the one from the Groovy dependency defined in the build script.

JavaScriptMinify

open class JavaScriptMinify : SourceTask

Task to minify JavaScript assets.

Javadoc

open class Javadoc : SourceTask

Generates HTML API documentation for Java classes.

If you create your own Javadoc tasks remember to specify the 'source' property! Without source the Javadoc task will not create any documentation. Example:

 apply plugin: 'java' task myJavadocs(type: Javadoc) { source = sourceSets.main.allJava } 

An example how to create a task that runs a custom doclet implementation:

 apply plugin: 'java' configurations { jaxDoclet } dependencies { //jaxDoclet "some.interesting:Dependency:1.0" } task generateRestApiDocs(type: Javadoc) { source = sourceSets.main.allJava destinationDir = reporting.file("rest-api-docs") options.docletpath = configurations.jaxDoclet.files.asType(List) options.doclet = "com.lunatech.doclets.jax.jaxrs.JAXRSDoclet" options.addStringOption("jaxrscontext", "http://localhost:8080/myapp") } 

JsHint

open class JsHint : SourceTask

Pmd

open class Pmd : SourceTask, VerificationTask, Reporting<PmdReports>

Runs a set of static code analysis rules on Java source code files and generates a report of problems found.

RoutesCompile

open class RoutesCompile : SourceTask

Task for compiling routes templates into Scala code.

This task is usually created as one of the build tasks when building a Play application with the org.gradle.play.plugins.PlayPlugin plugin. Explicit configuration of this task is not expected and should be performed on the equivalent settings at the org.gradle.play.PlayApplicationSpec level.

ScalaDoc

open class ScalaDoc : SourceTask

Generates HTML API documentation for Scala source files.

TwirlCompile

open class TwirlCompile : SourceTask

Task for compiling Twirl templates into Scala code.