3

I have an existing Eclipse plugin which run as a regular IDE plugin, receiving commands from the GUI and returning output in custom views.

I want to add an ability to also be able to run that plugin in headless mode, with the input received from the command-line and the output going to some file. Is there some way of modifying the existing plugin to support that mode of execution in addition to the existing regular execution, or do I have to create a new headless plugin and just use code from the first one?

Oak
  • 26,231
  • 8
  • 93
  • 152

1 Answers1

1

It depends on how you plan to use this plugin and the main question: is there a case, where your UI dependencies will not be available, i.e. whether there is a bundle configuration without SWT and RCP bundles?

No UI available

In this case, you'll need to extract the headless part of your plugin into new plugin, which then registers the headless entry point to it. The UI part of the plugin will depend on the new plugin and just delegate UI requests to the appropriate API in the headless part.

In order to provide headless application, you should take a look at org.eclipse.equinox.app.IApplication interface and respectively org.eclipse.equinox.applications extension point. When you've defined the application, you launch it by simply invoking:

eclipse -application <app-id> <app-param>

More information can be found in Eclipse Help.

UI available

The simpler case. Only the headless entry point needs to be specified and everything will work as previously.

My experience, however, shows that sooner or later, the case arise where the plugin needs to be split and depending on its complexity it might cause more trouble than it would have been if it was split earlier.

Danail Nachev
  • 19,231
  • 3
  • 21
  • 17
  • Can you explain what you mean by availability of UI dependencies? – Oak Jul 26 '11 at 21:45
  • It means that there is a different bundle configuration without SWT and RCP bundles. For example, Eclipse used to use so called basebuilder, which was stripped down version of Eclipse, which excluded the UI bundles and used it only for building plugins. Such configuration I consider to be missing UI dependencies or the UI layer itself. – Danail Nachev Jul 27 '11 at 08:10
  • Adding an IApplication and running it by choosing a different eclipse application seems to work, though now I'm wary because of your previous experience :) in any case thank you for the answer. – Oak Jul 27 '11 at 21:05
  • http://stackoverflow.com/questions/39407800/eclipse-by-default-run-eclipse-plugin-headless Can you look at this question? – Abhishek Tiwari Sep 12 '16 at 07:22