eclipse-emfmodel-driven-development

How to generate Java-code from model of EMF


I created a model with EMF and generated an Eclipse plugin for this model. In the plugin I can now define an instance of that model. But now I want do generate Java-code from this instance. How can I do this?


Solution

  • You should first create a GenModel from you eCore Model. New -> Create -> EMF Generator Model -> From eCore -> Select you eCore. Then click on the top-level element of this model and pick Generate All.

    EDIT: There is not way to directly generate Java from custom model. You have to use JET, Accelo or xTend2 to write you generator. Or, you can probably take a look at xText project.