api / org.gradle.api.provider

Package org.gradle.api.provider

Types

HasMultipleValues

interface HasMultipleValues<T : Any>

Represents a property whose value can be set using multiple elements of type T, such as a collection property.

Note: This interface is not intended for implementation by build script or plugin authors. You can use the factory methods on org.gradle.api.model.ObjectFactory to create instances of this interface.

ListProperty

interface ListProperty<T : Any> : Provider<MutableList<T>>, HasMultipleValues<T>

Represents a property whose type is a List of elements of type T.

Note: This interface is not intended for implementation by build script or plugin authors. An instance of this class can be created through the factory method org.gradle.api.model.ObjectFactory#listProperty(Class).

Property

interface Property<T : Any> : Provider<T>

A Provider representation for capturing the state of a property. The value can be provided by using the method #set(Object) or #set(Provider).

Note: This interface is not intended for implementation by build script or plugin authors. An instance of this class can be created through the factory method org.gradle.api.model.ObjectFactory#property(Class). There are also several specialized subtypes of this interface that can be created using various other factory methods.

PropertyState

interface PropertyState<T : Any> : Property<T>

A Provider representation for capturing the state of a property. The value can be provided by using the method #set(Object) or #set(Provider).

Note: This interface is not intended for implementation by build script or plugin authors. An instance of this class can be created through the factory methods org.gradle.api.Project#property(java.lang.Class) or org.gradle.api.provider.ProviderFactory#property(java.lang.Class).

Provider

interface Provider<T : Any>

A container object that provides a value of a specific type. The value can be retrieved by the method #get() or #getOrNull().

A provider may not always have a value available, for example when the value may not yet be known but will be known at some point in the future. When a value is not available, #isPresent() returns false and retrieving the value will fail with an exception.

A provider may not always provide the same value. Although there are no methods on this interface to change the value, the provider implementation may be mutable or use values from some changing source.

A provider may provide a value that is mutable and that changes over time.

A typical use of a provider is to pass values from one DSL element to another, e.g. from an extension to a task. Providers also allow expensive computations to be deferred until their value is actually needed, usually at task execution time.

For a provider whose value can be mutated, see Property.

Do not use Provider<File>. Use org.gradle.api.file.Directory or org.gradle.api.file.RegularFile instead.

Note: This interface is not intended for implementation by build script or plugin authors. An instance of this class can be created through the factory methods org.gradle.api.Project#provider(java.util.concurrent.Callable) or org.gradle.api.provider.ProviderFactory#provider(java.util.concurrent.Callable).

ProviderFactory

interface ProviderFactory

A factory for creating instances of Provider and PropertyState.

An instance of the factory can be injected into a task or plugin by annotating a public constructor or method with javax.inject.Inject.

 public class MyTask extends DefaultTask { // injection into a constructor @javax.inject.Inject public MyTask(ProviderFactory providerFactory) { } // injection into a method @javax.inject.Inject public ProviderFactory getProviderFactory() { throw new UnsupportedOperationException(); } } 

An instance of the factory is also available using Project#getProviders()

SetProperty

interface SetProperty<T : Any> : Provider<MutableSet<T>>, HasMultipleValues<T>

Represents a property whose type is a Set of elements of type T. Retains iteration order.

Note: This interface is not intended for implementation by build script or plugin authors. An instance of this class can be created through the factory method org.gradle.api.model.ObjectFactory#setProperty(Class).