interface Convention : ExtensionContainer
A Convention
manages a set of convention objects. When you add a convention object to a Convention
, and the properties and methods of the convention object become available as properties and methods of the object which the convention is associated to. A convention object is simply a POJO or POGO. Usually, a Convention
is used by plugins to extend a org.gradle.api.Project or a org.gradle.api.Task.
abstract fun <T : Any> findPlugin(type: Class<T>): T
Locates the plugin convention object with the given type. |
|
abstract fun getExtensionsAsDynamicObject(): DynamicObject
Returns a dynamic object which represents the properties and methods contributed by the extensions and convention objects contained in this convention. |
|
abstract fun <T : Any> getPlugin(type: Class<T>): T
Locates the plugin convention object with the given type. |
|
abstract fun getPlugins(): MutableMap<String, Any>
Returns the plugin convention objects contained in this convention. |
abstract fun <T : Any> add(publicType: Class<T>, name: String, extension: T): Unit abstract fun <T : Any> add(publicType: TypeOf<T>, name: String, extension: T): Unit
Adds a new extension to this container. Adding an extension of name 'foo' will:
publicType .
abstract fun add(name: String, extension: Any): Unit
Adds a new extension to this container. Adding an extension of name 'foo' will:
extension.getClass() unless the extension itself declares a preferred public type via the org.gradle.api.reflect.HasPublicType protocol.
|
|
abstract fun <T : Any> configure(type: Class<T>, action: Action<in T>): Unit abstract fun <T : Any> configure(type: TypeOf<T>, action: Action<in T>): Unit
Looks for the extension of the specified type and configures it with the supplied action. abstract fun <T : Any> configure(name: String, action: Action<in T>): Unit
Looks for the extension with the specified name and configures it with the supplied action. |
|
abstract fun <T : Any> create(publicType: Class<T>, name: String, instanceType: Class<out T>, vararg constructionArguments: Any): T abstract fun <T : Any> create(publicType: TypeOf<T>, name: String, instanceType: Class<out T>, vararg constructionArguments: Any): T
Creates and adds a new extension to this container. A new instance of the given abstract fun <T : Any> create(name: String, type: Class<T>, vararg constructionArguments: Any): T
Creates and adds a new extension to this container. A new instance of the given |
|
abstract fun findByName(name: String): Any
Looks for the extension of a given name. If none found null is returned. |
|
abstract fun <T : Any> findByType(type: Class<T>): T abstract fun <T : Any> findByType(type: TypeOf<T>): T
Looks for the extension of a given type (useful to avoid casting). If none found null is returned. |
|
abstract fun getByName(name: String): Any
Looks for the extension of a given name. If none found it will throw an exception. |
|
abstract fun <T : Any> getByType(type: Class<T>): T abstract fun <T : Any> getByType(type: TypeOf<T>): T
Looks for the extension of a given type (useful to avoid casting). If none found it will throw an exception. |
|
abstract fun getExtensionsSchema(): ExtensionsSchema
Provides access to the schema of all known extensions. |
|
abstract fun getExtraProperties(): ExtraPropertiesExtension
The extra properties extension in this extension container. This extension is always present in the container, with the name “ext”. |
|
abstract fun
Provides access to all known extensions types. |
fun <T : Any> Convention.findPlugin(): T? fun <T : Any> Convention.findPlugin(conventionType: KClass<T>): T? |
|
fun <T : Any> Convention.getPlugin(): T fun <T : Any> Convention.getPlugin(conventionType: KClass<T>): T |
|
fun <T : Any> Convention.getPluginByName(name: String): T
Looks for the convention plugin of a given name and casts it to the expected type T. |