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.

build.gradle : IDE から Gradle が読み込まれていることを判定する (Android Studio, IntelliJ IDEA)

Posted at

build.gradle が IDE から読み込まれていることは idea.active プロパティで判定できます。

IDE がプロジェクトを読み込んだり Gradle Tasks リストを読み出すときには idea.active = "true" がセットされています。

build.gradle.kts
val ideaActive = (System.getProperty("idea.active") == "true")

if (ideaActive) {
    // IDE から読み込まれているときだけ実行したい処理
}

公式のドキュメントは見当たりませんでしたが、Gradle Plugin 作成時のテクニックなどで使われているようです。

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?