Created
April 5, 2016 10:49
-
-
Save cbeams/21e37a720e89e8e8e45d017a39a61ccf to your computer and use it in GitHub Desktop.
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
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