// tag::after-evaluate[]
allprojects {
    afterEvaluate { project ->
        if (project.hasTests) {
            println "Adding test task to $project"
            project.task('test') {
                doLast {
                    println "Running tests for $project"
                }
            }
        }
    }
}
// end::after-evaluate[]

allprojects {
    ext.hasTests = false
}
