api / org.gradle.api.plugins / PluginManager / apply

apply

abstract fun apply(pluginId: String): Unit

Applies the plugin with the given ID. Does nothing if the plugin has already been applied.

Plugins in the "org.gradle" namespace can be applied directly via name. That is, the following two lines are equivalent…

 pluginManager.apply "org.gradle.java" pluginManager.apply "java" 

Parameters

pluginId - the ID of the plugin to apply

Since
2.3

abstract fun apply(type: Class<*>): Unit

Applies the given plugin. Does nothing if the plugin has already been applied.

The given class should implement the org.gradle.api.Plugin interface, and be parameterized for a compatible type of this.

The following two lines are equivalent…

 pluginManager.apply org.gradle.api.plugins.JavaPlugin pluginManager.apply "org.gradle.java" 

Parameters

type - the plugin class to apply

Since
2.3