# provider

abstract fun <T> provider(value: Callable<out @Nullable T>): Provider<T>(source)

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.

Configuration Cache

This provider is always computed and its value is cached by the Configuration Cache. If this provider is created at configuration time, the Callable may call configuration-time only APIs and capture objects of arbitrary types.

This can be useful when you need to lazily compute some value to use at execution time based on configuration-time only data. For example, you can compute an archive name based on the name and the version of the project:

      tasks.register("createArchive") {
          def archiveNameProvider = providers.provider { project.name + "-" + project.version + ".jar" }
          doLast {
              def archiveName = new File(archiveNameProvider.get())
              // ... create the archive and put in its contents.
          }
      }

Content copied to clipboard

#### Return

The provider. Never returns null.

#### Since

4.0

#### Parameters

value

The `java.util.concurrent.Callable` use to calculate the value.