Klasse ConfigureUtil
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 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 ObjectFactory.newInstance(Class, Object...).
As a last resort, to apply some configuration represented by a Groovy Closure, a plugin can use Project.configure(Object, Closure).
-
Verschachtelte Klassen - Übersicht
Verschachtelte KlassenModifizierer und TypKlasseBeschreibungstatic classVeraltet.static classVeraltet. -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic <T> TVeraltet.static <T> TconfigureByMap(Map<?, ?> properties, T delegate) Veraltet.static <T> TconfigureByMap(Map<?, ?> properties, T delegate, Collection<?> mandatoryKeys) Veraltet.static <T> TconfigureSelf(Closure configureClosure, T target) Veraltet.Called from an object'sConfigurable.configure(groovy.lang.Closure)method.static <T> TconfigureSelf(Closure configureClosure, T target, org.gradle.internal.metaobject.ConfigureDelegate closureDelegate) Veraltet.Called from an object'sConfigurable.configure(groovy.lang.Closure)method.static <T> Action<T> configureUsing(Closure configureClosure) Veraltet.Creates an action that uses the given closure to configure objects of type T.
-
Konstruktordetails
-
ConfigureUtil
public ConfigureUtil()Veraltet.
-
-
Methodendetails
-
configureByMap
Veraltet. -
configureByMap
Veraltet. -
configure
Veraltet.Configures
targetwithconfigureClosure, via theConfigurableinterface if necessary.If
targetdoes not implementConfigurableinterface, it is set as the delegate of a clone ofconfigureClosurewith a resolve strategy ofDELEGATE_FIRST.If
targetdoes implement theConfigurableinterface, theconfigureClosurewill be passed todelegate'sConfigurable.configure(Closure)method.- Parameter:
configureClosure- The configuration closuretarget- The object to be configured- Gibt zurück:
- The delegate param
-
configureUsing
Veraltet.Creates an action that uses the given closure to configure objects of type T. -
configureSelf
Veraltet.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) Veraltet.Called from an object'sConfigurable.configure(groovy.lang.Closure)method.
-