Distinguish between debug and release build in runtime?


I need something like:

if (isDebugBuild()) {
} else {

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?

Comment actions Permalink


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.

Comment actions Permalink

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 :)


Please sign in to leave a comment.