2

プロジェクトプロパティからプラグインコンベンションプロパティを設定する方法を理解しようとしています。

これは、gradleディストリビューションのcustomPluginWithConventionの例です(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'
}

プロジェクトプロパティなしでこのスクリプトを実行する:

>gradle hello
:hello
Hi from Gradle

BUILD SUCCESSFUL

そして今、プロジェクトプロパティを設定してカスタムメッセージを設定しようとしています:

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

予想される「さようなら」の代わりに、コンベンションのデフォルトの挨拶が表示されます。メッセージを上書きすることは可能ですか?

4

1 に答える 1

0

メッセージを上書きすることは可能ですか?

まだですが、それを可能にするよう努めるべきです。http://jira.codehaus.org/browse/GRADLEで問題を作成してください。

于 2011-02-03T06:15:27.667 に答える