api / org.gradle.api.plugins

Package org.gradle.api.plugins

Types

ApplicationPlugin

open class ApplicationPlugin : Plugin<Project>

A Plugin which runs a project as a Java Application.

The plugin can be configured via its companion ApplicationPluginConvention object.

ApplicationPluginConvention

open class ApplicationPluginConvention

The Convention used for configuring the ApplicationPlugin.

AppliedPlugin

interface AppliedPlugin

Represents a plugin that has been applied.

Currently just provides information about the ID of the plugin.

BasePlugin

open class BasePlugin : Plugin<Project>

A org.gradle.api.Plugin which defines a basic project lifecycle and some common convention properties.

BasePluginConvention

open class BasePluginConvention

A Convention used for the BasePlugin.

Convention

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.

ExtensionAware

interface ExtensionAware

Objects that can be extended at runtime with other objects.

 // Extensions are just plain objects, there is no interface/type class MyExtension { String foo MyExtension(String foo) { this.foo = foo } } // Add new extensions via the extension container project.extensions.create('custom', MyExtension, "bar") // («name», «type», «constructor args», …) // extensions appear as properties on the target object by the given name assert project.custom instanceof MyExtension assert project.custom.foo == "bar" // also via a namespace method project.custom { assert foo == "bar" foo = "other" } assert project.custom.foo == "other" // Extensions added with the extension container's create method are themselves extensible assert project.custom instanceof ExtensionAware project.custom.extensions.create("nested", MyExtension, "baz") assert project.custom.nested.foo == "baz" // All extension aware objects have a special “ext” extension of type ExtraPropertiesExtension assert project.hasProperty("myProperty") == false project.ext.myProperty = "myValue" // Properties added to the “ext” extension are promoted to the owning object assert project.myProperty == "myValue" 
Many Gradle objects are extension aware. This includes; projects, tasks, configurations, dependencies etc.

For more on adding & creating extensions, see ExtensionContainer.

For more on extra properties, see ExtraPropertiesExtension.

An ExtensionAware object has several 'scopes' that Gradle searches for properties. These scopes are:

  • The object itself. This scope includes any property getters and setters declared by the implementation class. The properties of this scope are readable or writable depending on the presence of the corresponding getter or setter method.
  • Groovy Meta-programming methods implemented by the object's class, like propertyMissing(). Care must be taken by plugin authors to ensure propertyMissing() is implemented such that if a property is not found a MissingPropertyException(String, Class) exception is thrown. If propertyMissing() always returns a value for any property, Gradle will not search the rest of the scopes below.
  • The extra properties of the object. Each object maintains a map of extra properties, which can contain any arbitrary name -> value pair. Once defined, the properties of this scope are readable and writable.
  • The extensions added to the object by plugins. Each extension is available as a read-only property with the same name as the extension.

ExtensionContainer

interface ExtensionContainer

Allows adding 'namespaced' DSL extensions to a target object.

ExtensionsSchema

interface ExtensionsSchema : MutableIterable<ExtensionSchema>

Schema of extensions.

ExtraPropertiesExtension

interface ExtraPropertiesExtension

Additional, ad-hoc, properties for Gradle domain objects.

Extra properties extensions allow new properties to be added to existing domain objects. They act like maps, allowing the storage of arbitrary key/value pairs. All ExtensionAware Gradle domain objects intrinsically have an extension named “{@value #EXTENSION_NAME}” of this type.

An important feature of extra properties extensions is that all of its properties are exposed for reading and writing via the ExtensionAware object that owns the extension.

 project.ext.set("myProp", "myValue") assert project.myProp == "myValue" project.myProp = "anotherValue" assert project.myProp == "anotherValue" assert project.ext.get("myProp") == "anotherValue" 
Extra properties extension objects support Groovy property syntax. That is, a property can be read via extension.«name» and set via extension.«name» = "value". Wherever possible, the Groovy property syntax should be preferred over the #get(String) and #set(String, Object) methods.
 project.ext { myprop = "a" } assert project.myprop == "a" assert project.ext.myprop == "a" project.myprop = "b" assert project.myprop == "b" assert project.ext.myprop == "b" 
You can also use the Groovy accessor syntax to get and set properties on an extra properties extension.
 project.ext["otherProp"] = "a" assert project.otherProp == "a" assert project.ext["otherProp"] == "a" 
The exception that is thrown when an attempt is made to get the value of a property that does not exist is different depending on whether the Groovy syntax is used or not. If Groovy property syntax is used, the Groovy groovy.lang.MissingPropertyException will be thrown. When the #get(String) method is used, an UnknownPropertyException will be thrown.

GroovyBasePlugin

open class GroovyBasePlugin : Plugin<Project>

Extends org.gradle.api.plugins.JavaBasePlugin to provide support for compiling and documenting Groovy source files.

GroovyPlugin

open class GroovyPlugin : Plugin<Project>

A Plugin which extends the JavaPlugin to provide support for compiling and documenting Groovy source files.

HelpTasksPlugin

open class HelpTasksPlugin : Plugin<ProjectInternal>

Adds various reporting tasks that provide information about the project.

JavaBasePlugin

open class JavaBasePlugin : Plugin<ProjectInternal>

A org.gradle.api.Plugin which compiles and tests Java source, and assembles it into a JAR file.

JavaLibraryDistributionPlugin

open class JavaLibraryDistributionPlugin : Plugin<ProjectInternal>

A Plugin which package a Java project as a distribution including the JAR and runtime dependencies.

JavaLibraryPlugin

open class JavaLibraryPlugin : Plugin<Project>

A Plugin which extends the capabilities of the JavaPlugin by cleanly separating the API and implementation dependencies of a library.

JavaPlugin

open class JavaPlugin : Plugin<ProjectInternal>

A Plugin which compiles and tests Java source, and assembles it into a JAR file.

JavaPluginConvention

open class JavaPluginConvention

Is mixed into the project when applying the org.gradle.api.plugins.JavaBasePlugin or the org.gradle.api.plugins.JavaPlugin.

MavenPlugin

open class MavenPlugin : Plugin<ProjectInternal>

A org.gradle.api.Plugin which allows project artifacts to be deployed to a Maven repository, or installed to the local Maven cache.

MavenPluginConvention

open class MavenPluginConvention : MavenPomMetaInfoProvider

Properties and methods added by the org.gradle.api.plugins.MavenPlugin.

MavenRepositoryHandlerConvention

interface MavenRepositoryHandlerConvention

Allows Maven repositories for publishing artifacts to be defined. The Maven plugin mixes-in this interface to the org.gradle.api.artifacts.dsl.RepositoryHandler associated with each task of type org.gradle.api.tasks.Upload.

ObjectConfigurationAction

interface ObjectConfigurationAction

An ObjectConfigurationAction allows you to apply org.gradle.api.Plugins and scripts to an object or objects.

PluginAware

interface PluginAware

Something that can have plugins applied to it.

The plugin manager can be used for applying and detecting whether plugins have been applied.

For more on writing and applying plugins, see org.gradle.api.Plugin.

PluginCollection

interface PluginCollection<T : Plugin<Any>> : DomainObjectSet<T>

A PluginCollection represents a collection of org.gradle.api.Plugin instances.

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.

PluginManager

interface PluginManager

Facilitates applying plugins and determining which plugins have been applied to a PluginAware object.

ProjectReportsPlugin

open class ProjectReportsPlugin : Plugin<Project>

A Plugin which adds some project visualization report tasks to a project.

ProjectReportsPluginConvention

open class ProjectReportsPluginConvention

The conventional configuration for the `ProjectReportsPlugin`.

ReportingBasePlugin

open class ReportingBasePlugin : Plugin<ProjectInternal>

A Plugin which provides the basic skeleton for reporting.

This plugin adds the following extension objects to the project:

  • org.gradle.api.reporting.ReportingExtension

WarPlugin

open class WarPlugin : Plugin<Project>

A Plugin which extends the JavaPlugin to add tasks which assemble a web application into a WAR file.

WarPluginConvention

open class WarPluginConvention

A Convention used for the WarPlugin.

Annotations

DeferredConfigurable

class DeferredConfigurable

Indicates that the annotated object is designed to be configured only once, and that changes to configuration inputs made after configuration should not be allowed.

Exceptions

InvalidPluginException

open class InvalidPluginException : GradleException

Thrown when a plugin is found to be invalid when it is loaded.

PluginInstantiationException

open class PluginInstantiationException : GradleException

A PluginInstantiationException is thrown when a plugin cannot be instantiated.

UnknownPluginException

open class UnknownPluginException : InvalidUserDataException

A UnknownPluginException is thrown when an unknown plugin id is provided.