Class ConfigureUtil
- java.lang.Object
-
- org.gradle.util.ConfigureUtil
-
@Deprecated public class ConfigureUtil extends java.lang.Object
Deprecated.Will be removed in Gradle 9.0.Contains utility methods to configure objects with Groovy Closures.Plugins should avoid using this class and methods that use
Closure
as this makes the plugin harder to use in other languages. Instead, plugins should create methods that useAction
. 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 withObjectFactory.newInstance(Class, Object...)
.As a last resort, to apply some configuration represented by a Groovy Closure, a plugin can use
Project.configure(Object, Closure)
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConfigureUtil.IncompleteInputException
Deprecated.static class
ConfigureUtil.WrappedConfigureAction<T>
Deprecated.
-
Constructor Summary
Constructors Constructor Description ConfigureUtil()
Deprecated.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <T> T
configure(Closure configureClosure, T target)
Deprecated.static <T> T
configureByMap(java.util.Map<?,?> properties, T delegate)
Deprecated.static <T> T
configureByMap(java.util.Map<?,?> properties, T delegate, java.util.Collection<?> mandatoryKeys)
Deprecated.static <T> T
configureSelf(Closure configureClosure, T target)
Deprecated.Called from an object'sConfigurable.configure(groovy.lang.Closure)
method.static <T> T
configureSelf(Closure configureClosure, T target, org.gradle.internal.metaobject.ConfigureDelegate closureDelegate)
Deprecated.Called from an object'sConfigurable.configure(groovy.lang.Closure)
method.static <T> Action<T>
configureUsing(Closure configureClosure)
Deprecated.Creates an action that uses the given closure to configure objects of type T.
-
-
-
Method Detail
-
configureByMap
public static <T> T configureByMap(java.util.Map<?,?> properties, T delegate)
Deprecated.
-
configureByMap
public static <T> T configureByMap(java.util.Map<?,?> properties, T delegate, java.util.Collection<?> mandatoryKeys)
Deprecated.
-
configure
public static <T> T configure(@Nullable Closure configureClosure, T target)
Deprecated.Configures
target
withconfigureClosure
, via theConfigurable
interface if necessary.If
target
does not implementConfigurable
interface, it is set as the delegate of a clone ofconfigureClosure
with a resolve strategy ofDELEGATE_FIRST
.If
target
does implement theConfigurable
interface, theconfigureClosure
will be passed todelegate
'sConfigurable.configure(Closure)
method.- Parameters:
configureClosure
- The configuration closuretarget
- The object to be configured- Returns:
- The delegate param
-
configureUsing
public static <T> Action<T> configureUsing(@Nullable Closure configureClosure)
Deprecated.Creates an action that uses the given closure to configure objects of type T.
-
configureSelf
public static <T> T configureSelf(@Nullable Closure configureClosure, T target)
Deprecated.Called from an object'sConfigurable.configure(groovy.lang.Closure)
method.
-
configureSelf
public static <T> T configureSelf(@Nullable Closure configureClosure, T target, org.gradle.internal.metaobject.ConfigureDelegate closureDelegate)
Deprecated.Called from an object'sConfigurable.configure(groovy.lang.Closure)
method.
-
-