Determining if plugin was launched from IDEA itself during plugin development

Answered

I know I can use PlatformUtils to determine which product is running, but how do I tell if I'm running from a copy of IDEA that was launched by IDEA itself during plugin development. i.e. I'm currently developing my plugin, regardless of which platform it is running.

0
4 comments

You can pass specific jvm option in debug environment and check it with System.getProperty.
For example: `-Didea.debug.mode=true`.

0

If you want to do what Aleksey just said and you use Gradle for your build, you will want to add the following to your `runIde` task:

/* Propagate VM options from gradle command line through to the plugin. */
systemProperties = System.getProperties()

Otherwise, Gradle gets the options, instead of the secondary instance.  Just as a matter of course, I would stay away from the "idea" namespace for properties that you set for your own benefit.

If it's just for your local development, you could also check `PathManager.getHomePath()` for the location the instance is running from.  In the secondary instance, you will get the sandbox directory.  You obviously wouldn't want to ship something like that.

0

Thanks this helps. I realized I also need to detect the equivalent of a debug flag from another process. Is the best way to do that to look for a "java.exe" process (other platforms use another name like "idea64.exe") or is there a cleaner way? Is there some way to detect the package/bundle name such as "com.jetbrains.intellij" or "com.jetbrains.intellij-EAP"? I've seen closed source implementations that get this value on OSX, but I'm on Windows.

0

Please sign in to leave a comment.