api / org.gradle.api.plugins / PluginContainer

PluginContainer

interface PluginContainer : PluginCollection<Plugin<Any>>

A PluginContainer is used to manage a set of org.gradle.api.Plugin instances applied to a particular project.

Plugins can be specified using either an id or type. The id of a plugin is specified using a META-INF/gradle-plugins/${id}.properties classpath resource.

Functions

apply

abstract fun apply(id: String): Plugin<Any>

Has the same behavior as #apply(Class) except that the plugin is specified via its id. Not all plugins have an id.

abstract fun <T : Plugin<Any>> apply(type: Class<T>): T

Applies a plugin to the project. This usually means that the plugin uses the project API to add and modify the state of the project. This method can be called an arbitrary number of times for a particular plugin type. The plugin will be actually used only the first time this method is called.

findPlugin

abstract fun findPlugin(id: String): Plugin<Any>

Returns the plugin for the given id.

abstract fun <T : Plugin<Any>> findPlugin(type: Class<T>): T

Returns the plugin for the given type.

getAt

abstract fun getAt(id: String): Plugin<Any>

Returns a plugin with the specified id if this plugin has been used in the project. You can use the Groovy [] operator to call this method from a build script.

abstract fun <T : Plugin<Any>> getAt(type: Class<T>): T

Returns a plugin with the specified type if this plugin has been used in the project. You can use the Groovy [] operator to call this method from a build script.

getPlugin

abstract fun getPlugin(id: String): Plugin<Any>

Returns a plugin with the specified id if this plugin has been used in the project.

abstract fun <T : Plugin<Any>> getPlugin(type: Class<T>): T

Returns a plugin with the specified type if this plugin has been used in the project.

hasPlugin

abstract fun hasPlugin(id: String): Boolean

Returns true if the container has a plugin with the given id, false otherwise.

abstract fun hasPlugin(type: Class<out Plugin<Any>>): Boolean

Returns true if the container has a plugin with the given type, false otherwise.

withId

abstract fun withId(pluginId: String, action: Action<in Plugin<Any>>): Unit

Executes or registers an action for a plugin with given id. If the plugin was already applied, the action is executed. If the plugin is applied sometime later the action will be executed after the plugin is applied. If the plugin is never applied, the action is never executed. The behavior is similar to #withType(Class, org.gradle.api.Action).

Inherited Functions

add

abstract fun add(element: T): Boolean

Unsupported.

addAll

abstract fun addAll(elements: Collection<T>): Boolean

Unsupported.

clear

abstract fun clear(): Unit

Unsupported.

matching

abstract fun matching(spec: Spec<in T>): PluginCollection<T>
abstract fun matching(closure: Closure<Any>): PluginCollection<T>

{@inheritDoc}

remove

abstract fun remove(o: T): Boolean

Unsupported.

removeAll

abstract fun removeAll(elements: Collection<T>): Boolean

Unsupported.

whenPluginAdded

abstract fun whenPluginAdded(action: Action<in T>): Action<in T>

Adds an Action to be executed when a plugin is added to this collection.

abstract fun whenPluginAdded(closure: Closure<Any>): Unit

Adds a closure to be called when a plugin is added to this collection. The plugin is passed to the closure as the parameter.

withType

abstract fun <S : T> withType(type: Class<S>): PluginCollection<S>

{@inheritDoc}