gradle
8.3

# configure

abstract fun configure(object: Any, configureClosure: Closure): Any

Configures an object via a closure, with the closure's delegate set to the supplied object. This way you don't have to specify the context of a configuration statement multiple times.

Instead of:

    MyType myType = new MyType()
    myType.doThis()
    myType.doThat()

Content copied to clipboard

you can do:

    MyType myType = configure(new MyType()) {
        doThis()
        doThat()
    }

Content copied to clipboard

The object being configured is also passed to the closure as a parameter, so you can access it explicitly if required:

    configure(someObj) { obj -> obj.doThis() }

Content copied to clipboard

#### Return

The configured object

#### Parameters

object

The object to configure

configureClosure

The closure with configure statements

abstract fun configure(objects: Iterable<out Any>, configureClosure: Closure): Iterable<out Any>

Configures a collection of objects via a closure. This is equivalent to calling configure for each of the given objects.

#### Return

The configured objects.

#### Parameters

objects

The objects to configure

configureClosure

The closure with configure statements

abstract fun <T> configure(objects: Iterable<T>, configureAction: Action<out Any>): Iterable<T>

Configures a collection of objects via an action.

#### Return

The configured objects.

#### Parameters

objects

The objects to configure

configureAction

The action to apply to each object