A PluginContainer
is used to manage a set of 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.
Type | Name and description |
---|---|
Plugin |
apply(String id) Has the same behavior as apply(Class) except that the plugin is specified via its id. |
T |
apply(Class<T> type) Applies a plugin to the project. |
Plugin |
findPlugin(String id) Returns the plugin for the given id. |
T |
findPlugin(Class<T> type) Returns the plugin for the given type. |
Plugin |
getAt(String id) Returns a plugin with the specified id if this plugin has been used in the project. |
T |
getAt(Class<T> type) Returns a plugin with the specified type if this plugin has been used in the project. |
Plugin |
getPlugin(String id) Returns a plugin with the specified id if this plugin has been used in the project. |
T |
getPlugin(Class<T> type) Returns a plugin with the specified type if this plugin has been used in the project. |
boolean |
hasPlugin(String id) Returns true if the container has a plugin with the given id, false otherwise. |
boolean |
hasPlugin(Class<? extends Plugin> type) Returns true if the container has a plugin with the given type, false otherwise. |
void |
withId(String pluginId, Action<? super Plugin> action) Executes or registers an action for a plugin with given id. |
Methods inherited from class | Name |
---|---|
interface PluginCollection |
matching, matching, whenPluginAdded, whenPluginAdded, withType |
interface DomainObjectSet |
findAll, matching, matching, withType |
interface DomainObjectCollection |
all, all, findAll, matching, matching, whenObjectAdded, whenObjectAdded, whenObjectRemoved, whenObjectRemoved, withType, withType, withType |
interface Set |
add, remove, equals, hashCode, clear, contains, isEmpty, iterator, size, toArray, toArray, spliterator, addAll, containsAll, removeAll, retainAll, stream, removeIf, parallelStream, forEach |
Has the same behavior as apply(Class) except that the plugin is specified via its id. Not all plugins have an id.
id
- The id of the plugin to be applied.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.
type
- The type of the plugin to be usedReturns the plugin for the given id.
id
- The id of the pluginReturns the plugin for the given type.
type
- The type of the plugin 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.
id
- The id of the plugin 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.
type
- The type of the pluginReturns a plugin with the specified id if this plugin has been used in the project.
id
- The id of the pluginReturns a plugin with the specified type if this plugin has been used in the project.
type
- The type of the pluginReturns true if the container has a plugin with the given id, false otherwise.
id
- The id of the pluginReturns true if the container has a plugin with the given type, false otherwise.
type
- The type of the pluginExecutes 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).
pluginId
- the id of the pluginaction
- the action