# add

abstract fun <T> add(publicType: Class<T>, name: String, extension: T)(source)
abstract fun <T> add(publicType: TypeOf<T>, name: String, extension: T)(source)

Adds a new extension to this container. Adding an extension of name 'foo' will:

- add 'foo' dynamic property
- add 'foo' dynamic method that accepts a closure that is a configuration script block

The extension will be exposed as `publicType`.

#### Since

3.5

#### Parameters

publicType

The extension public type

name

The name for the extension

extension

Any object implementing `publicType`

#### Throws

java.lang.IllegalArgumentException

When an extension with the given name already exists.

abstract fun add(name: String, extension: Any)(source)

Adds a new extension to this container. Adding an extension of name 'foo' will:

- add 'foo' dynamic property
- add 'foo' dynamic method that accepts a closure that is a configuration script block

The extension will be exposed as `extension.getClass()` unless the extension itself declares a preferred public type via the org.gradle.api.reflect.HasPublicType protocol.

#### Parameters

name

The name for the extension

extension

Any object

#### Throws

java.lang.IllegalArgumentException

When an extension with the given name already exists