Distinguish between debug and release build in runtime?

已回答

I need something like:

if (isDebugBuild()) {
  foo()
} else {
  bar()
}

My question is: is there API that works like isDebugBuild() in my example?

P.S. In case such API does not exist, is there another API which tells us whether it is unit-test run or normal launch?

0

Hi,

There is no API for checking if an IDE is run in debug mode. Please clarify your use case, so maybe we will find another solution.

For checking if a code is run from a unit test, please check com.intellij.openapi.application.Application.isUnitTestMode() similar methods in this class.

0

We develop plugin for internal use. We would like to understand how much it is used. So that we implemented sending analytical events.

However, we don`t need those analytical events when developing plugin (debug runs) or running unit tests.

P.S. com.intellij.openapi.application.Application.isUnitTestMode() is able to prevent analytical events related to unit-tests. It is better than nothing, so I would consider it Plan B :)

0

请先登录再写评论。