LoginSignup
0
0

More than 3 years have passed since last update.

[Gradle]gradleのコマンド引数でビルド設定を切り替える

Posted at

プロジェクトプロパティを使う。

要点

  • build.gradleからはproject.properties[""]でプロジェクトプロパティを参照する
  • gradleのコマンド実行時に-P=でプロジェクトプロパティを設定する

Boolean値のビルド設定を切り替える例を示す。

build.gradle
def foobar = project.properties.getOrDefault('foobar', '').toBoolean()

android {
    buildTypes {
        debug {
            debuggable foobar
        }
    }
}
コマンド
# foobarをtrueにする
./gradlew app:assembleDebug -Pfoobar=true

デフォルトはdebuggableはfalseだが、コマンドで指定したときのみtrueになる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0