gradle
8.5

# ConfigureUtil

open class ConfigureUtil(source)

### Deprecated

Contains utility methods to configure objects with Groovy Closures.

Plugins should avoid using this class and methods that use groovy.lang.Closure as this makes the plugin harder to use in other languages. Instead, plugins should create methods that use Action. Here's an example pseudocode:

        interface MyOptions {
            RegularFileProperty getOptionsFile()
        }
        abstract class MyExtension {
            private final MyOptions options

            @Inject abstract ObjectFactory getObjectFactory()

            public MyExtension() {
                this.options = getObjectFactory().newInstance(MyOptions)
            }

            public void options(Action<? extends MyOptions>  action) {
                 action.execute(options)
            }
        }
        extensions.create("myExtension", MyExtension)
        myExtension {
            options {
                optionsFile = layout.projectDirectory.file("options.properties")
            }
        }

Content copied to clipboard

Gradle automatically generates a Closure-taking method at runtime for each method with an Action as a single argument as long as the object is created with newInstance.

As a last resort, to apply some configuration represented by a Groovy Closure, a plugin can use configure.

#### Deprecated

Will be removed in Gradle 9.0.

## Constructors

ConfigureUtil
Link copied to clipboard
constructor()

## Types

IncompleteInputException
Link copied to clipboard
open class IncompleteInputException : RuntimeException
Incomplete input exception.
WrappedConfigureAction
Link copied to clipboard
open class WrappedConfigureAction<T> : Action<T>
Wrapper configure action.

## Functions

configure
Link copied to clipboard
open fun <T> configure(@Nullable configureClosure: Closure, target: T): T
Configures `target` with `configureClosure`, via the Configurable interface if necessary.
configureByMap
Link copied to clipboard
open fun <T> configureByMap(properties: Map<out Any, out Any>, delegate: T): T
open fun <T> configureByMap(properties: Map<out Any, out Any>, delegate: T, mandatoryKeys: Collection<out Any>): T
configureSelf
Link copied to clipboard
open fun <T> configureSelf(@Nullable configureClosure: Closure, target: T): T
open fun <T> configureSelf(@Nullable configureClosure: Closure, target: T, closureDelegate: ConfigureDelegate): T
Called from an object's configure method.
configureUsing
Link copied to clipboard
open fun <T> configureUsing(@Nullable configureClosure: Closure): Action<T>
Creates an action that uses the given closure to configure objects of type T.