まず、ユーザディレクトリの.gradleディレクトリに以下のファイルを作成する(名前は、other.gradleとする)。
次に、任意のプロジェクトのbuild.gradleで、apply fromを使って上記のother.gradleを読み込む。ext.prop1 = 'value1'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the contents of .gradle/other.gradle is: | |
// ext.prop1 = 'value1' | |
apply from: "${System.properties['user.home']}/.gradle/other.gradle" | |
task testProperties << { | |
println project.prop1 | |
} |
上記のbuild.gradleで定義したタスクを実行した結果は、以下の通り。
> gradle -q testProperties value1
関連リンク
- Gradle本家ユーザガイド
0 件のコメント:
コメントを投稿