For AI agents: the documentation index is at https://docs.gradle.org/llms.txt. Request any page with the header Accept: text/markdown to get Markdown. User manual pages are also available as Markdown by replacing .html with .md in the URL.

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

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.

Since

1.0

Parameters

name

The name for the extension

extension

Any object

Throws

When an extension with the given name already exists