// tag::after-evaluate[]
gradle.beforeProject { project ->
    // Set a default value
    project.ext.set("hasTests", false)
}

gradle.afterProject { project ->
    if (project.ext.has("hasTests") && project.ext.get("hasTests")) {
        val projectString = project.toString()
        println("Adding test task to $projectString")
        tasks.register("test") {
            doLast {
                println("Running tests for $projectString")
            }
        }
    }
}
// end::after-evaluate[]

// tag::after-evaluate[]
gradle.beforeProject {
    // Set a default value
    project.ext.set("hasTests", false)
}

gradle.afterProject {
    if (project.ext.has("hasTests") && project.ext.get("hasTests")) {
        val projectString = project.toString()
        println("Adding test task to $projectString")
        tasks.register("test") {
            doLast {
                println("Running tests for $projectString")
            }
        }
    }
}
// end::after-evaluate[]

Remove explicit project arg from kotlin
Remove explicit project arg from kotlin

gradle/gradle,gradle/gradle,gradle/gradle,gradle/gradle,gradle/gradle,gradle/gradle,gradle/gradle,gradle/gradle,gradle/gradle,gradle/gradle