I tried as per example in, and simplified it to just "message".
class GreetingPlugin implements Plugin<Project> {
void apply(Project project) {
def extension = project.extensions.create('greeting', GreetingPluginExtension, project)
project.tasks.create('hello', Greeting) {
message = extension.message
}
}
}
class GreetingPluginExtension {
def String message = "aa"
GreetingPluginExtension(Project project) {
message = project.property(String)
}
}
class Greeting extends DefaultTask {
@Input
def String message = project.property(String)
@TaskAction
def testCoverageVerification() {
logger.quiet("Message is")
logger.quiet(message)
}
}
apply plugin: GreetingPlugin
greeting {
message = 'Hi from Gradle'
}
When I run ./gradlew -q hello, I got
Message is
value: null
I expect it to be
Message is
value: Hi from Gradle
Why did my String from the greeting fail to pass in?