开发者

Override plugin convention property with project property

I am trying to understand how to set a plugin convention property from a project property.

Here is the customPluginWithConvention example from the gradle distribution (gradle-0.9.2\samples\userguide\organizeBuildLogic\customPluginWithConvention\build.gradle)

apply plugin: GreetingPlugin

greeting = 'Hi from Gradle'

class GreetingPlugin implements Plugin<Project> {
    def void apply(Project project) {
        project.convention.plugins.greet = new GreetingPluginConvention()
        project.task('hello') << {
            println project.convention.plugins.greet.greeting
  开发者_运维技巧      }
    }
}

class GreetingPluginConvention {
    def String greeting = 'Hello from GreetingPlugin'
}

Running this script with no project property:

>gradle hello
:hello
Hi from Gradle

BUILD SUCCESSFUL

And now trying to set a custom message via setting a project property:

>gradle -Pgreeting=goodbye hello
:hello
Hello from GreetingPlugin

Instead of the expected "goodbye" the default greeting of the convention is shown. Is it possible to override the message?


Is it possible to override the message?

Not yet, but we should try to make it possible. Please create an issue at http://jira.codehaus.org/browse/GRADLE.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜