Skip to content

Instantly share code, notes, and snippets.

@cbeams
Created April 5, 2016 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbeams/21e37a720e89e8e8e45d017a39a61ccf to your computer and use it in GitHub Desktop.
Save cbeams/21e37a720e89e8e8e45d017a39a61ccf to your computer and use it in GitHub Desktop.
apply plugin: GreetingPlugin
// Configure the 'greeting' extension object
greeting {
// Configure its 'message' property
message = 'Hi!'
}
class GreetingPlugin implements Plugin<Project> {
void apply(Project project) {
// Create the 'greeting' extension object
project.extensions.create("greeting", GreetingPluginExtension)
// Create a task that uses the configuration
project.task('greet') << {
println project.greeting.message
}
}
}
class GreetingPluginExtension {
// Declare the 'message' property and assign it a default value
def String message = 'Hello from GreetingPlugin'
}
/*** expected output ***\
$ gradle greet
:greet
Hi!
BUILD SUCCESSFUL
\***********************/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment