create

abstract fun create(options: Map<String, out Any>): Task(source)

Creates a Task and adds it to this container. A map of creation options can be passed to this method to control how the task is created. The following options are available:

{@value org.gradle.api.Task#TASK_NAME}The name of the task to create.None. Must be specified.
{@value org.gradle.api.Task#TASK_TYPE}The class of the task to create.org.gradle.api.DefaultTask
{@value org.gradle.api.Task#TASK_ACTION}The closure or Action to execute when the task executes. See doFirst.null
{@value org.gradle.api.Task#TASK_OVERWRITE}Replace an existing task?false
{@value org.gradle.api.Task#TASK_DEPENDS_ON}The dependencies of the task. See here for more details.[]
{@value org.gradle.api.Task#TASK_GROUP}The group of the task.null
{@value org.gradle.api.Task#TASK_DESCRIPTION}The description of the task.null
{@value org.gradle.api.Task#TASK_CONSTRUCTOR_ARGS}The arguments to pass to the task class constructor.null

After the task is added, it is made available as a property of the project, so that you can reference the task by name in your build file.

If a task with the given name already exists in this container and the {@value org.gradle.api.Task#TASK_OVERWRITE} option is not set to true, an exception is thrown.

Return

The newly created task object

Parameters

options

The task creation options.

See also

More information about how tasks are exposed by name in build scripts

Throws

If a task with the given name already exists in this project.

If any of the values in {@value org.gradle.api.Task#TASK_CONSTRUCTOR_ARGS} is null.


abstract fun create(options: Map<String, out Any>, configureClosure: Closure): Task(source)

Creates a Task adds it to this container. A map of creation options can be passed to this method to control how the task is created. See create for the list of options available. The given closure is used to configure the task before it is returned by this method.

After the task is added, it is made available as a property of the project, so that you can reference the task by name in your build file.

Return

The newly created task object

Parameters

options

The task creation options.

configureClosure

The closure to use to configure the task.

See also

More information about how tasks are exposed by name in build scripts

Throws

If a task with the given name already exists in this project.


abstract fun create(name: String, configureClosure: Closure): Task(source)

Creates a Task with the given name adds it to this container. The given closure is used to configure the task before it is returned by this method.

After the task is added, it is made available as a property of the project, so that you can reference the task by name in your build file.

Return

The newly created task object

Parameters

name

The name of the task to be created

configureClosure

The closure to use to configure the task.

See also

More information about how tasks are exposed by name in build scripts

Throws

If a task with the given name already exists in this project.


abstract fun create(name: String): Task(source)

Creates a Task with the given name and adds it to this container.

After the task is added, it is made available as a property of the project, so that you can reference the task by name in your build file.

Return

The newly created task object

Parameters

name

The name of the task to be created

See also

More information about how tasks are exposed by name in build scripts

Throws

If a task with the given name already exists in this project.


abstract fun <T : Task?> create(name: String, type: Class<T>): T(source)

Creates a Task with the given name and type, and adds it to this container.

After the task is added, it is made available as a property of the project, so that you can reference the task by name in your build file.

Return

The newly created task object

Parameters

name

The name of the task to be created.

type

The type of task to create.

See also

More information about how tasks are exposed by name in build scripts

Throws

If a task with the given name already exists in this project.


abstract fun <T : Task?> create(name: String, type: Class<T>, constructorArgs: Array<Any>): T(source)

Creates a Task with the given name and type, passing the given arguments to the @Inject-annotated constructor, and adds it to this container. All values passed to the task constructor must be non-null; otherwise a NullPointerException will be thrown

After the task is added, it is made available as a property of the project, so that you can reference the task by name in your build file.

Return

The newly created task object

Since

4.7

Parameters

name

The name of the task to be created.

type

The type of task to create.

constructorArgs

The arguments to pass to the task constructor

See also

More information about how tasks are exposed by name in build scripts

Throws

If a task with the given name already exists in this project.

If any of the values in constructorArgs is null.


abstract fun <T : Task?> create(name: String, type: Class<T>, configuration: Action<in T>): T(source)

Creates a Task with the given name and type, configures it with the given action, and adds it to this container.

After the task is added, it is made available as a property of the project, so that you can reference the task by name in your build file.

Return

The newly created task object.

Parameters

name

The name of the task to be created.

type

The type of task to create.

configuration

The action to configure the task with.

See also

More information about how tasks are exposed by name in build scripts

Throws

If a task with the given name already exists in this project.