Access Lazy Property at Configuration Time

How can I access the value of a org.gradle.api.provider.Property at configuration time? All Kotlin examples shown in access the properties within the @TaskAction at execution time.

Example use case:
A custom task with a Property<AbstractArchiveTask>. If I wand to dependOn this archive task, I cannot do this within the task action as this would be to late. Adding the dependsOn in the task constructor is to early, as the property is not yet set at this time.

Is there some sort of listener on the properties that fires when the value is set?

You can call dependsOn with the Property<AbstractArchiveTask> as early as you want. It doesn’t matter that the value is not yet set. As it is a Provider, Gradle will handle resolving the actual value later in the lifecycle when it is needed, which will be after it has been set in the configuration phase.

You are right. I can set the dependency within the constructor of the custom task. However I have to change the type of the property to Property<TaskProvider<out AbstractCopyTask>> to make the lazy configuration work.

open class Greeting : DefaultTask() {

    val dependency: Property<TaskProvider<out AbstractCopyTask>> =
    val greeting: Property<String> =

    init {

    fun printMessage() {

val prepare by tasks.registering(Copy::class) {

tasks.register<Greeting>("greeting") {

My mistate was to call dependency.get() within the constructor, which obviously does not work. Switching to a TaskProvider does the trick.

Thank you for your help!