To create eclipse plugins, you need an eclipse distribution package with Eclipse Plug-in Development Environment like Eclipse Standard or Eclipse IDE for Java EE. I am using Eclipse Standard 4.3.2. Always try to use the latest version of the distribution available. You can start exploring from eclipse site at http://www.eclipse.org/downloads to check the package contents of the distribution package. Once the correct distribution package is downloaded, extract and run eclipse.exe (Windows), eclipse (Linux), or Eclipse.app (OS X) to start eclipse, selecting a workspace folder to store your project files. The workspace folder will be created if not already present.
To create eclipse plugins using eclipse, we need to create a Plug-in Project first. Navigate to File > New > Project > Plug-in Project (under Plug-in Development) to start the New Plug-in Project wizard. You can also navigate as File > New > Other > Plug-in Project (under Plug-in Development). You can also upgrade an existing Java project to a plug-in project by navigating to Configure > Convert to plug-in project, but here we will only see how to use New Plug-in Project wizard. The Eclipse-developed plugin names usually start with org.eclipse (e.g. org.eclipse.ui). After the New Plug-in Project wizard starts, enter project name following the convention (e.g. com.javajee.eclplugin.hello). According to eclipse naming conventions all plug-ins must have unique identifiers similar to the naming convention of Java packages. Leave other entries and selections with their defaults, and click next until you reach Templates page. In the Templates page, select “Hello, World”, click next, make any changes to messages and click finish. This template adds a Sample Menu to the menu bar and a button to the tool bar, and both of these invoke the same Sample Action which will open a simple message dialog with a message you just configured.
Previous steps will create a sample plugin project which you can modify to add more features. To run this project, right click the project and run as ‘Eclipse Application’. A new eclipse instance will be launched with this plugin. Since we used the “Hello, World” template, you should see a new Menu called ‘Sample Menu’. Navigate to Sample Menu> Sample Action and you should see a dialog with the message you had configured. Now you can explore the created project and try to make some changes like changing the message etc.
Three key files generated are META-INF/MANIFEST.MF, plugin.xml and build.properties.
The MANIFEST.MF describes the plug-in's name, version, dependencies etc.
The plugin.xml file declares what extensions this plug-in provide to the Eclipse runtime. Non-UI plug-ins often doesn’t need to have plugin.xml file.
<?xml version="1.0" encoding="UTF-8"?>
label="Sample Action Set"
tooltip="Hello, Eclipse world"
Text labels (e.g. Sample Action) for the commands, actions and menus, tooltips etc. are represented in the plugin.xml file and hence Eclipse can show the menus before loading or executing any code. Try changing these values and run as eclipse again.
The build.properties file contains reference to resources used and is used mainly during development and build process.
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
Just double click in eclipse and use the Build tab in Build Configurations to edit this file.
Book: Eclipse 4 Plug-in Development by Example Beginner's Guide by Dr Alex Blewitt.