Is there a away to check if my plugin is running locally?

Answered

Hi, I want to manage releases (dev/staging/prod) on my plugin and I thought that differentiating between dev and the others would be easy: I'd just check if the plugin is running local, but I haven't managed to find to way to check that.

Is there a way to check isRunningLocal() or isRunningDeployed() ?

0
6 comments

Gilad,

What do you mean by "running locally"? Do you want to check if you're testing your plugin across the CI? Or is it a version installed from the repository or by the manual installation or just run from the IJ during the development?

 

In general, SDK provides you with methods such as Application.isUnitTestMode() or Application.isHeadlessEnvironment().

If you want to detect the difference between the builds, I'd suggest you prepare builds with suffixes like 1.0.0-dev, 1.0.0-staging or 1.0.0

Having the version containing environment suffix, you can verify it checking the version string:

PluginManager.getPlugin(id).getVersion()

 

0

Jakub Chrzanowski

Hi, i'll make my question clearer,

how do I know if the current code (of the plugin) is running locally on my computer using runIde task or, it is running as a deployed plugin?

 

Thank you very much for your time

0

There is no straight forward way to check in the IJ SDK that its instance is running triggered by the Gradle task or as a "real" IDE.

As said above - you can introduce version suffix that may be overwritten by the Grade task (Patching DLS section). In your Gradle configuration, you can use the environment variable (called i.e., "VERSION_SUFFIX"), which will be provided by the local task and skipped (fallback to an empty string) when built for production.

intellij {
  version ideaVersion + System.getenv().getOrDefault('VERSION_SUFFIX', '')
// ...
}

Then you can edit the runIde configuration and provide VERSION_SUFFIX that you'll test against during the runtime.

0

You could just put a dummy file somewhere and check for its existence.

0

Thank you for your help!

0

val isDevelopmentMode = System.getProperty("idea.is.internal") == "true"

0

Please sign in to leave a comment.