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")
        }
    }

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

Link copied to clipboard
constructor()

Types

Link copied to clipboard
Incomplete input exception.
Link copied to clipboard
Wrapper configure action.

Functions

Link copied to clipboard
open fun <T> configure(@Nullable configureClosure: Closure, target: T): T
Configures target with configureClosure, via the Configurable interface if necessary.
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
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.
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.