Table of Contents
API Documentation: | ProviderFactory |
---|
A factory for creating instances of Provider
.
An instance of the factory can be injected into a task, plugin or other object by annotating a public constructor or property getter method with javax.inject.Inject
.
It is also available via Project.getProviders()
and Settings.getProviders()
.
Method | Description |
credentials(credentialsType, identity) | Creates a |
credentials(credentialsType, identity) | Creates a |
environmentVariable(variableName) | Creates a |
environmentVariable(variableName) | Creates a |
environmentVariablesPrefixedBy(variableNamePrefix) | Creates a |
environmentVariablesPrefixedBy(variableNamePrefix) | Creates a |
exec(action) | Allows lazy access to the output of the external process. |
fileContents(file) | Allows lazy access to the contents of the given file. |
fileContents(file) | Allows lazy access to the contents of the given file. |
gradlePropertiesPrefixedBy(variableNamePrefix) | Creates a |
gradlePropertiesPrefixedBy(variableNamePrefix) | Creates a |
gradleProperty(propertyName) | Creates a |
gradleProperty(propertyName) | Creates a |
javaexec(action) | Allows lazy access to the output of the external java process. |
of(valueSourceType, configuration) | Creates a |
provider(value) | Creates a |
systemPropertiesPrefixedBy(variableNamePrefix) | Creates a |
systemPropertiesPrefixedBy(variableNamePrefix) | Creates a |
systemProperty(propertyName) | Creates a |
systemProperty(propertyName) | Creates a |
zip(first, second, combiner) | Returns a provider which value will be computed by combining a provider value with another provider value using the supplied combiner function. |
Creates a Provider
for the given Credentials
type.
The provider returned by this method should be attached to a task's input property. This way, the presence of credentials will be validated before any of the tasks are executed if and only if the task with credentials property is to be executed.
Values for the requested Credentials type will be sourced from the project's properties using the pattern "identity" + credentials field.
For example, PasswordCredentials
provider with identity "myService" will look for properties named "myServiceUsername" and "myServicePassword".
The following credential types are currently supported:
Creates a Provider
for the given Credentials
type.
The provider returned by this method should be attached to a task's input property. This way, the presence of credentials will be validated before any of the tasks are executed if and only if the task with credentials property is to be executed.
Values for the requested Credentials type will be sourced from the project's properties using the pattern "identity" + credentials field.
For example, PasswordCredentials
provider with identity "myService" will look for properties named "myServiceUsername" and "myServicePassword".
The following credential types are currently supported:
Creates a Provider
whose value is fetched from the environment variable with the given name.
Creates a Provider
whose value is fetched from the environment variable with the given name.
Creates a Provider
whose value is a name-to-value map of the environment variables with the names starting with the given prefix.
The prefix comparison is case-sensitive. The returned map is immutable.
Creates a Provider
whose value is a name-to-value map of the environment variables with the names starting with the given prefix.
The prefix comparison is case-sensitive. The returned map is immutable.
ExecOutput
exec
(Action
<? super ExecSpec
>
action)
Action
<? super ExecSpec
>Allows lazy access to the output of the external process.
When the process output is read at configuration time it is considered as an input to the configuration model. Consequent builds will re-execute the process to obtain the output and check if the cached model is still up-to-date.
The process input and output streams cannot be configured.
For more sophisticated use cases, like handling execution exceptions, supplying input streams or processing the output in a streaming way, use ValueSource
.
FileContents
fileContents
(RegularFile
file)
Allows lazy access to the contents of the given file.
When the file contents are read at configuration time the file is automatically considered as an input to the configuration model.
FileContents
fileContents
(Provider
<RegularFile
>
file)
Provider
<RegularFile
>Allows lazy access to the contents of the given file.
When the file contents are read at configuration time the file is automatically considered as an input to the configuration model.
Creates a Provider
whose value is a name-to-value map of the Gradle properties with the names starting with the given prefix.
The prefix comparison is case-sensitive. The returned map is immutable.
Creates a Provider
whose value is a name-to-value map of the Gradle properties with the names starting with the given prefix.
The prefix comparison is case-sensitive. The returned map is immutable.
Creates a Provider
whose value is fetched from the Gradle property of the given name.
Creates a Provider
whose value is fetched from the Gradle property of the given name.
ExecOutput
javaexec
(Action
<? super JavaExecSpec
>
action)
Action
<? super JavaExecSpec
>Allows lazy access to the output of the external java process.
When the process output is read at configuration time it is considered as an input to the configuration model. Consequent builds will re-execute the process to obtain the output and check if the cached model is still up-to-date.
The process input and output streams cannot be configured.
For more sophisticated use cases, like handling execution exceptions, supplying input streams or processing the output in a streaming way, use ValueSource
.
Provider
<T
>
of
(Class
<? extends ValueSource
<T
, P
>>
valueSourceType, Action
<? super ValueSourceSpec
<P
>>
configuration)
Provider
<T
>Class
<? extends ValueSource
<T
, P
>>Action
<? super ValueSourceSpec
<P
>>Creates a Provider
whose value is obtained from the given ValueSource
.
Creates a Provider
whose value is calculated using the given Callable
.
The provider is live and will call the Callable
each time its value is queried. The Callable
may return null
, in which case the provider is considered to have no value.
Creates a Provider
whose value is a name-to-value map of the system properties with the names starting with the given prefix.
The prefix comparison is case-sensitive. The returned map is immutable.
Creates a Provider
whose value is a name-to-value map of the system properties with the names starting with the given prefix.
The prefix comparison is case-sensitive. The returned map is immutable.
Creates a Provider
whose value is fetched from system properties using the given property name.
Creates a Provider
whose value is fetched from system properties using the given property name.
Provider
<R
>
zip
(Provider
<A
>
first, Provider
<B
>
second, BiFunction
<? super A
, ? super B
, ? extends R
>
combiner)
Provider
<R
>Provider
<A
>Provider
<B
>BiFunction
<? super A
, ? super B
, ? extends R
>Returns a provider which value will be computed by combining a provider value with another provider value using the supplied combiner function.
The resulting provider will be live, so that each time it is queried, it queries both supplied providers and applies the combiner to the results. Whenever any of the providers has no value, the new provider will also have no value and the combiner will not be called.
If the supplied providers represents a task or the output of a task, the resulting provider will carry the dependency information.