apply plugin: GreetingPlugin

// our default greeting
greeting = "Hello!"

task hello(type: GreetingTask)

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

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

class GreetingTask extends DefaultTask {

    String greeting

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