Skip to content

Instantly share code, notes, and snippets.

@shapeoflambda
Last active March 24, 2019 17:51
Show Gist options
  • Save shapeoflambda/9a6519db4c3a35f15d9f5529f0ec71bf to your computer and use it in GitHub Desktop.
Save shapeoflambda/9a6519db4c3a35f15d9f5529f0ec71bf to your computer and use it in GitHub Desktop.
Gradle plugin that takes argument
class GreetingPluginExtension {
String message
String greeter
}
class GreetingPlugin implements Plugin<Project> {
void apply(Project project) {
def extension = project.extensions.create('greeting', GreetingPluginExtension)
project.task('hello') {
doLast {
println "${extension.message} from ${extension.greeter}"
}
}
}
}
apply plugin: GreetingPlugin
// Configure the extension using a DSL block
greeting {
message = 'Hi'
greeter = 'Gradle'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment