Programmatically running EMF code generation
I have created an EMF model with extension .system
which will generate the code for my work.
Now I can generate code using launch code generation action from Eclipse. But I want to generate the code by launching the code generation from a stand-alone program.
How do I achieve this?
Details: I have created a plugin from EMF model and have inlcluded in the Eclipse.
I will created .system
files from out of my plugin and I can generate code from my plugins.
I have observed that when I click launch the code generation it is starting a LauchAction
class from my plugin.
How do I start my LaunchAction
class from a stand-alone Java program?
My aim is to run my created .system
model and generate the code from a stand-alone Java program.
How d开发者_运维问答o I achieve this?
You could call Eclipse from the command line. Something similar to this:
eclipse.exe -noSplash -data ${workspace_location} -model -edit -editor -tests -application org.eclipse.emf.codegen.ecore.Generator ${genmodel}
This command will start Eclipse silently and will generate mode code (-model
), edit plug-in (-edit
), editor plug-in (-editor
), and the test plug-in (-tests
). Leave out any of these parameters if they are not needed.
I don't know how to solve your problem, but I think it is doable. I think you have to look at the EMF source code to check how the code generation works.
Here are some starting points:
If you have PDE and the EMF tools, use use Import > Plug-ins and Fragments to get the EMF plugin into your Eclipse workspace.
Otherwise, clone and import the following Git repository:
https://git.eclipse.org/c/emf/org.eclipse.emf.git/
Have a look at the following file, maybe you can find what you need there:
plugins/org.eclipse.emf.codegen.ecore.ui/src/org/eclipse/emf/codegen/ecore/genmodel/handler/GenerateHandler.java
Otherwise, look in the
org.eclipse.emf.codegen.ecore
plugin.
Good luck! It's an interesting problem! Please report back here if you solve it!
EDIT: Ops, this question is 10 years old, I didn't notice!
精彩评论