@NonExtensible public interface ProviderFactory
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()
.
Modifier and Type | Method | Description |
---|---|---|
<T extends Credentials> |
credentials(Class<T> credentialsType,
String identity) |
Creates a
Provider for the given Credentials type. |
<T extends Credentials> |
credentials(Class<T> credentialsType,
Provider<String> identity) |
Creates a
Provider for the given Credentials type. |
Provider<String> |
environmentVariable(String variableName) |
Creates a
Provider whose value is fetched from the environment variable with the given name. |
Provider<String> |
environmentVariable(Provider<String> variableName) |
Creates a
Provider whose value is fetched from the environment variable with the given name. |
FileContents |
fileContents(RegularFile file) |
Allows lazy access to the contents of the given file.
|
FileContents |
fileContents(Provider<RegularFile> file) |
Allows lazy access to the contents of the given file.
|
Provider<String> |
gradleProperty(String propertyName) |
Creates a
Provider whose value is fetched from the Gradle property of the given name. |
Provider<String> |
gradleProperty(Provider<String> propertyName) |
Creates a
Provider whose value is fetched from the Gradle property of the given name. |
<T,P extends ValueSourceParameters> |
of(Class<? extends ValueSource<T,P>> valueSourceType,
Action<? super ValueSourceSpec<P>> configuration) |
Creates a
Provider whose value is obtained from the given ValueSource . |
<T> Provider<T> |
provider(Callable<? extends T> value) |
|
Provider<String> |
systemProperty(String propertyName) |
Creates a
Provider whose value is fetched from system properties using the given property name. |
Provider<String> |
systemProperty(Provider<String> propertyName) |
Creates a
Provider whose value is fetched from system properties using the given property name. |
<A,B,R> |
zip(Provider<A> first,
Provider<B> second,
BiFunction<A,B,R> combiner) |
Returns a provider which value will be computed by combining a provider value with another
provider value using the supplied combiner function.
|
<T> Provider<T> provider(Callable<? extends T> value)
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.
value
- The java.util.concurrent.Callable
use to calculate the value.@Incubating Provider<String> environmentVariable(String variableName)
Provider
whose value is fetched from the environment variable with the given name.
The returned provider cannot be queried at configuration time but can produce a configuration time provider
via Provider.forUseAtConfigurationTime()
.variableName
- The name of the environment variable.@Incubating Provider<String> environmentVariable(Provider<String> variableName)
Provider
whose value is fetched from the environment variable with the given name.
The returned provider cannot be queried at configuration time but can produce a configuration time provider
via Provider.forUseAtConfigurationTime()
.variableName
- The provider for the name of the environment variable; when the given provider has no value, the returned provider has no value.@Incubating Provider<String> systemProperty(String propertyName)
Provider
whose value is fetched from system properties using the given property name.
The returned provider cannot be queried at configuration time but can produce a configuration time provider
via Provider.forUseAtConfigurationTime()
.propertyName
- the name of the system property@Incubating Provider<String> systemProperty(Provider<String> propertyName)
Provider
whose value is fetched from system properties using the given property name.
The returned provider cannot be queried at configuration time but can produce a configuration time provider
via Provider.forUseAtConfigurationTime()
.propertyName
- the name of the system property@Incubating Provider<String> gradleProperty(String propertyName)
Provider
whose value is fetched from the Gradle property of the given name.
The returned provider cannot be queried at configuration time but can produce a configuration time provider
via Provider.forUseAtConfigurationTime()
.propertyName
- the name of the Gradle property@Incubating Provider<String> gradleProperty(Provider<String> propertyName)
Provider
whose value is fetched from the Gradle property of the given name.
The returned provider cannot be queried at configuration time but can produce a configuration time provider
via Provider.forUseAtConfigurationTime()
.propertyName
- the name of the Gradle property@Incubating FileContents fileContents(RegularFile file)
file
- the file whose contents to read.FileContents.getAsText()
,
FileContents.getAsBytes()
@Incubating FileContents fileContents(Provider<RegularFile> file)
file
- provider of the file whose contents to read.FileContents.getAsText()
,
FileContents.getAsBytes()
@Incubating <T,P extends ValueSourceParameters> Provider<T> of(Class<? extends ValueSource<T,P>> valueSourceType, Action<? super ValueSourceSpec<P>> configuration)
Provider
whose value is obtained from the given ValueSource
.
The returned provider cannot be queried at configuration time but can produce a configuration time provider
via Provider.forUseAtConfigurationTime()
.valueSourceType
- the type of the ValueSource
configuration
- action to configure the parameters to the given ValueSource
@Incubating <T extends Credentials> Provider<T> credentials(Class<T> credentialsType, String identity)
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:
credentialsType
- type of credentials to be provided.identity
- identity to be associated with the credentials.@Incubating <T extends Credentials> Provider<T> credentials(Class<T> credentialsType, Provider<String> identity)
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:
credentialsType
- type of credentials to be provided.identity
- a provider returning the identity to be associated with the credentials.@Incubating <A,B,R> Provider<R> zip(Provider<A> first, Provider<B> second, BiFunction<A,B,R> combiner)
A
- the type of the first providerB
- the type of the second providerR
- the type of the result of the combinerfirst
- the first provider to combine withsecond
- the second provider to combine withcombiner
- the combiner of values