0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

男坂Advent Calendar 2020

Day 4

[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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?