Configure Util
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.
Types
Functions
Link copied to clipboard
Link copied to clipboard
open fun <T> configureSelf(@Nullable configureClosure: Closure, target: T, closureDelegate: ConfigureDelegate): T
Called from an object's configure method.
Link copied to clipboard
Creates an action that uses the given closure to configure objects of type T.