(nnn.)code2code is an eclipse plugin to generate source code from templates.
You can easily create your custom generators using known template engines: Groovy (JSP like), Freemarker or Velocity.
See it in action here.
Note: nnn.code2code is a fork of code2code with extra features (save/load parameters, allow overwride)
The files:
HelloWorld.generator
|-- templates
|-- HelloWorldTemplate.txt.ftl
|-- ListParams.ftl
|-- templates.ftl
|-- postactions.ftl
|-- params.ftl
Contents of HelloWorldTemplate.txt.ftl:
Hello ${name}!!!
Contents of ListParams.ftl:
Print vars => name=${name}
Contents of params.ftl:
name=World
Contents of templates.ftl:
templates/HelloWorldTemplate.txt.ftl=src/destinationPath/HelloWorld.txt
Contents of postactions.ftl
templates/ListParams.ftl
Installing generators: just create a folder named "generators" at the root of your project, and place your generators there.
Running generators: The plugin adds a " Generate... " option to your project context menu (right-click menu). Run it, choose one of your installed generators, set its parameters, and the plugin will generate the files to the right place.
See it in action here: Quickly cruding with code2code plugin and VRaptor2.
Inner params:
- eclipse_project_name : name of selected project
- eclipse_project_path : path of selected project
- eclipse_plugin_name : name of this plugin
- eclipse_plugin_version : version of this plugin
Current version is 0.10.7, tested against Eclipse Kepler SR2.
You can install it from the Update Site
http://wiki.github.com/nnn-dev/code2code
http://github.com/nnn-dev/code2code/issues
http://github.com/nnn-dev/code2code-example-generators/downloads