provider

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

Creates a Provider implementation based on the provided 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 = { project.name + "-" + project.version + ".jar" }
      doLast {
          def archiveName = new File(archiveNameProvider.get())
          // ... create the archive and put in its contents.
      }
  }

Return

The provider. Never returns null.

Since

4.0

Parameters

value

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

See also

Throws

If the provided value is null.