プロジェクトプロパティからプラグインコンベンションプロパティを設定する方法を理解しようとしています。
これは、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
予想される「さようなら」の代わりに、コンベンションのデフォルトの挨拶が表示されます。メッセージを上書きすることは可能ですか?