Export a generator as an Eclipse Plug-in
This document explains how one may export a generator as a Plug-In. The generator is then deployable in any Eclipse instance.
It describes the process to export the generator and the use of the Module Launcher helping users to setup a generator project in a few clicks
Cédric Brun, Obeo (France)
Every Acceleo generator project is also an Eclipse Plug-In project. It means the generator has a plugin.xml file and a Manifest.mf file in its META-INF folder
In order to be buildable as a plugin, an Acceleo generator should extend the fr.obeo.acceleo.gen.module extension point.
In order to do that, edit the Manifest.mf file , then clic on the Extensions tab, then on Add....
Now choose the fr.obeo.acceleo.gen.module extension point and click on Finish.
You should now create a module child by right-clicking on the extension point.
The module settings are only used by the Module Launcher, which use is described in the last part of this tutorial. If you don't need the Module Launcher then setting accurate property values here is not mandatory.
Make sure all the files used in the generator are exported, check in the build tab that every required file is checked, especially the .mt files and the plugin.xml file.
Building a generator follows the same process as building a standard Eclipse plugin. Right-click on the project and choose Export... then Deployable plug-ins and fragments.
|Figure :Export as plugin|
Click on "Next"
Eclipse will start building the project as soon as you click on Finish. A Jar file will be created in the output folder.
You may install this plugin in any Eclipse instance by copying the file in its plugins folder.
With a few more settings you'll be able to use the project initialization environment : the Module Launcher.
The Module Launcher provides ready to use generators. It will provide yours according to the following conditions :
Start by creating a .chain file launching the generation and put it in any folder of your generator project (here we chose the default folder).
Then you have to define the needed parameters by editing the Parameter Files attribute of the .chain file root element. Here our generator needs 3 parameters : the input model, the output folder and the log file.
You now need to describe these parameters in the extension point, then the Module Launcher will be able to prompt the user for their values.
Edit the plugin.xml file and go in the Extensions tab. Fill-in the required values for the Module: title, module's description, the path to the generic .chain file and optionally the module's category.
We'll now specify each .chain parameter, right click on the Module in the extensions editor and add as much children as you have parameters defined in your chain file (3 in our case).
You should define every parameter of the .chain file with its description, its type (file, folder or project), the file's extension and optionaly a default file to initialize the content.
The declaration order of these parameters should be the same as in the .chain parameters, these parameters will be substituted with the user values.
That's it ! You may now use the generator in a few clicks, you have to export it as a plugin and test it in a new Eclipse instance. Keep in mind to check the export parameters in the build tab, especially the fact that the default files used to initialize the parameters are exported during the build.