Running and debugging a plugin project

Running or debugging a plugin project is not different than how we do it with a Java project. Simply click on the green play button in the toolbar to give a go to our Hello World plugin. You will see that a new Eclipse instance will start. By default, this Eclipse instance contains all of the plugins installed in your development environment, plus every plugin project that's open in your workspace. This test instance is called Runtime Workbench.

Look for an Eclipse symbol in the toolbar of your runtime workbench. Click on it, and you'll be greeted with the Hello, Eclipse World message.

Debugging works just the same. Stop the current runtime workbench by clicking on the red square button in the console or by closing the Eclipse window. Place a breakpoint in the SampleAction class (on line 59), and hit the Debug button in the toolbar (the one with a green bug). Now, click on our Hello World button in the runtime workbench. The execution will be halted in the selected line. Everything that was discussed in Chapter 3, Unit Testing with JUnit and Debugging about debugging is also valid here.

Running and debugging configurations

Eclipse provides further configurations for running and debugging plugin applications. In the top menu, select Run | Run Configurations to take a closer look at them.

In the Main tab, you will be able to select the workspace location for the runtime workbench. That's where the projects you create while testing and debugging your application will be stored. You can choose to clear the workspace before starting the runtime workbench by clicking on the Clear option beneath the workspace location. The Program to Run section in the Main tab allows you to choose a different product or application to run, and Java Runtime Environment allows you to use a different JRE for the runtime environment. This can be useful if you are testing your plugin's compatibility with different JRE's.

The Arguments tab allows you to choose arguments both for Eclipse and for JVM to be used when launching the runtime workbench.

The plugins tab allows you to select the plugins that will be loaded in the runtime workbench, both from your Workspace and from your development environment. This can be useful to test your workspace projects individually without having to close them, or to remove the unrelated plugins from the development environment to save your machine's resources. The following screenshot displays the Plugins tab of the Run Configurations menu:

Running and debugging configurations

In the Configuration tab, you can set the config.ini file that you want to use for the runtime workbench instance, as well as modify the configuration area. The Tracing tab allows you to enable tracing for each plugin. Tracing is an interesting feature that allows you to turn on or off debug messages during runtime. This can be particularly useful if you are providing support for an Eclipse-based application installed in the client's environment. You can simply require the client to enable tracing for your plugin instead of sending him or her a debug version of the plugin with debug messages enabled. We won't cover tracing on this book. The Environment and Common tabs are just the same as in a regular Java application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset