Last active
March 24, 2019 17:51
-
-
Save shapeoflambda/9a6519db4c3a35f15d9f5529f0ec71bf to your computer and use it in GitHub Desktop.
Gradle plugin that takes argument
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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