# create

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

### Deprecated

Use register or register instead. See documentation for more information.

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

Project

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

#### Throws

InvalidUserDataException

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

NullPointerException

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

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

### Deprecated

Use register instead. See documentation for more information.

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

Project

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

#### Throws

InvalidUserDataException

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

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

### Deprecated

Use register instead. See documentation for more information.

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

Project

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

#### Throws

InvalidUserDataException

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

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

### Deprecated

Use register instead. See documentation for more information.

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

Project

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

#### Throws

InvalidUserDataException

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

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

### Deprecated

Use register instead. See documentation for more information.

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

Project

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

#### Throws

InvalidUserDataException

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)

### Deprecated

Use register instead. See documentation for more information.

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

Project

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

#### Throws

InvalidUserDataException

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

NullPointerException

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)

### Deprecated

Use register instead. See documentation for more information.

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

Project

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

#### Throws

InvalidUserDataException

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

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

### Deprecated

Use register instead. See documentation for more information.

Creates a Task with the given name and of type org.gradle.api.DefaultTask, 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.

configuration

The action to configure the task with.

#### See also

Project

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

#### Throws

InvalidUserDataException

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