api / org.gradle.api.provider / Provider / map


abstract fun <S : Any> map(transformer: Transformer<out S, in T>): Provider<S>

Returns a new Provider whose value is the value of this provider transformed using the given function.

The new provider will be live, so that each time it is queried, it queries this provider and applies the transformation to the result. Whenever this provider has no value, the new provider will also have no value.

Note that the new provider may cache the result of the transformations and so there is no guarantee that the transformer is called on every query of the new provider. The new provider will apply the transformation lazily, and calculate the value for the new provider when queried.


transformer - The transformer to apply to values. Should not return null.