apply plugin: GreetingPlugin

// our default greeting
greeting = "Hello!"

task hello(type: GreetingTask)

task bonjour(type: GreetingTask) {
    greeting = "Bonjour!"
}

class GreetingPlugin implements Plugin<Project> {
    void apply(Project project) {
        project.tasks.withType(GreetingTask) { task ->
            task.conventionMapping.greeting = { project.greeting }
        }
    }
}

class GreetingTask extends DefaultTask {

    String greeting

    @TaskAction
    def greet() {
        println getGreeting()
    }
}
