-
-
Notifications
You must be signed in to change notification settings - Fork 70
Liveplugin as an entry point for standard plugins
Dmitry Kandalov edited this page Apr 12, 2014
·
9 revisions
Even though liveplugin uses Groovy for plugin code it is possible to use liveplugin for (re)loading plugins written in any other JVM language. In particular with existing plugins written in Java. The trick is to compile/pack output into jar and use // add-to-classpath
in plugin.groovy to add jar to classpath.
As an example I partially did it for Code Glance plugin, you can see source code in this Code Glance fork.
These are the steps:
- checkout source code into folder with liveplugins (e.g.
~/Library/Application Support/IntelliJIdea13/live-plugins/CodeGlance
) - configure jar file generation on compilation. Project Settings -> Artifacts -> Add Jar From project modules with dependencies. Tick "Build on make" checkbox.
- create
plugin.groovy
with content like this (in a way this code duplicates content of plugin.xml because you need load/reload the same components):
import net.vektah.codeglance.CodeGlancePlugin
import static liveplugin.PluginUtil.changeGlobalVar
import static liveplugin.PluginUtil.show
// The path below should point to the jar file generated by IDEA
// add-to-classpath $HOME/Library/Application Support/IntelliJIdea13/live-plugins/CodeGlance/classes/artifacts/CodeGlance_jar/*.jar
if (isIdeStartup) return
changeGlobalVar("codeGlance"){ previousPlugin ->
if (previousPlugin != null) {
previousPlugin.disposeComponent()
show("Disposed previous CodeGlancePlugin")
}
def plugin = new CodeGlancePlugin(project)
plugin.initComponent()
plugin
}
show("Reloaded CodeGlancePlugin")
- make code changes to properly dispose the plugin (e.g. see diffs for Code Glance)
- load plugin through liveplugin (alt + C, E). If something is not working, check initialization or disposal of plugin.
That's it. And the whole point obviously is to shorten feedback loop by avoiding IDE restarts.