9

Is there a way to programmatically get the version of an IntelliJ IDEA plugin?

I'm creating my own IntelliJ IDEA plugin, and I have set the version property in the plugin.xml(e.g.:<version>3.1.1</version>). I need to get the version to display in the "About" dialog of my plugin. Is there a way to get this value programmatically?

I'm new to IntelliJ IDEA plugin development, if there is a different way to display a version number please let me know.

RoshFsk
  • 305
  • 2
  • 11

1 Answers1

12

Here you go mate:

PluginManager.getPlugin(PluginId.getId("my.plugin.id")).getVersion();

Edit: from 2020, use

PluginManagerCore.getPlugin
vikingsteve
  • 38,481
  • 23
  • 112
  • 156
  • 2
    How to get the version of Intellij Idea (not the plugin) programmatically? – Junius May 15 '17 at 08:34
  • @Junius ask that as a separate question and I'll answer it ;) – vikingsteve Oct 24 '17 at 10:08
  • 1
    thx for the answer. `PluginManager.getPlugin` was deprecated with build 193.2252. It still exists as of 2020.3 pending removal but was internally replaced by `PluginManagerCore.getPlugin`. Once removal is executed compatibility issues will unfortunately occur. – adietisheim Jan 28 '21 at 13:59