api / org.gradle.api.plugins / ExtensionContainer / add

add

@Incubating abstract fun <T : Any> add(publicType: Class<T>, name: String, extension: T): Unit
@Incubating abstract fun <T : Any> add(publicType: TypeOf<T>, name: String, extension: T): Unit

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

The extension will be exposed as publicType.

Parameters

publicType - The extension public type

name - The name for the extension

extension - Any object implementing publicType

Exceptions

IllegalArgumentException - When an extension with the given name already exists.

Since
3.5

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

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

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

Exceptions

IllegalArgumentException - When an extension with the given name already exists