2011-02-02 45 views
1

我想了解如何從項目屬性設置一個插件約定財產。覆蓋插件約定財產與工程屬性

下面是從gradle這個分佈customPluginWithConvention例子(gradle這個-0.9.2 \樣本\ 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' 
} 

沒有項目屬性運行此腳本:

>gradle hello 
:hello 
Hi from Gradle 

BUILD SUCCESSFUL 

而現在嘗試通過設置項目屬性來設置自定義消息:

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

而不是預期的「再見」的約定的默認問候的顯示。是否可以重寫消息?

回答

0

是否可以忽略此消息?

還沒有,但我們應該努力使之成爲可能。請http://jira.codehaus.org/browse/GRADLE創建一個問題。

+0

謝謝,提交:http://jira.codehaus.org/browse/GRADLE-1365 – mdi 2011-02-03 13:34:05