Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to invoke the code generation programmatically
How to invoke the code generation programmatically [message #468127] Tue, 04 August 2009 10:04 Go to next message
Timothy Marc is currently offline Timothy MarcFriend
Messages: 547
Registered: July 2009
Senior Member
Hi all,

currently, i'm defining my own metamodel and i had to invoke the
model/edit/editor part generation step by hand. I guess, that it is also
possible to do this via an API programmatically within a ANT script
(some more batch steps like javadoc references, etc.).

Is there a tutorial or a hint, how to achieve this?

Thanks a lot
Timothy
Re: How to invoke the code generation programmatically [message #468131 is a reply to message #468127] Tue, 04 August 2009 10:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

invoke the generation programmatically works with this snippet:

ISelectionService selectionService =
Activator.getDefault().getWorkbench().getActiveWorkbenchWind ow().getSelectionService();
ISelection selection = selectionService.getSelection();
if(selection instanceof IStructuredSelection){
IStructuredSelection strucSel = (IStructuredSelection)selection;
if(strucSel.size() == 1){
if(strucSel.getFirstElement() instanceof GenModel){
GenModel genModel = (GenModel) strucSel.getFirstElement();
Generator generator = new Generator();
generator.setInput(genModel);

generator.generate(genModel,
GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE, new BasicMonitor());
generator.generate(genModel,
GenBaseGeneratorAdapter.EDIT_PROJECT_TYPE, new BasicMonitor());
}
}
}

This starts the generation of the model and the edit code for example.
Re: How to invoke the code generation programmatically [message #468132 is a reply to message #468127] Tue, 04 August 2009 10:28 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Timothy,

A google search for "emf generate ant" scores this one high:

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org .eclipse.emf/plugins/org.eclipse.emf.ant/readme.html?root=Mo deling_Project&view=co

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Timothy Marc schrieb:
> Hi all,
>
> currently, i'm defining my own metamodel and i had to invoke the
> model/edit/editor part generation step by hand. I guess, that it is
> also possible to do this via an API programmatically within a ANT
> script (some more batch steps like javadoc references, etc.).
>
> Is there a tutorial or a hint, how to achieve this?
>
> Thanks a lot
> Timothy


Re: How to invoke the code generation programmatically [message #468140 is a reply to message #468127] Tue, 04 August 2009 10:43 Go to previous message
Tas Frangoullides is currently offline Tas FrangoullidesFriend
Messages: 195
Registered: July 2009
Senior Member
Hi Timothy,

There are already emf tasks for doing this. Something along the lines of

<emf.Ecore2Java
genmodel="path/to/genmodel"
modelproject="path/to/modelProject"
modelprojectfragmentpath="src">
...
</emf.Ecore2Java>

Sorry I am not sure on the details. There are also XSD2Java, Rose2Java and
JET related tasks too.

I don't know of any tutorials but someone else might.

Hope that helps somewhat.
Tas.

"Timothy Marc" <timothymarc@freenet.de> wrote in message
news:h5913b$o9j$1@build.eclipse.org...
> Hi all,
>
> currently, i'm defining my own metamodel and i had to invoke the
> model/edit/editor part generation step by hand. I guess, that it is also
> possible to do this via an API programmatically within a ANT script (some
> more batch steps like javadoc references, etc.).
>
> Is there a tutorial or a hint, how to achieve this?
>
> Thanks a lot
> Timothy
Previous Topic:[Teneo] Undo / Redo resource save issue
Next Topic:copy ResourceSet containing metamodel and model
Goto Forum:
  


Current Time: Wed Apr 24 21:15:13 GMT 2024

Powered by FUDForum. Page generated in 0.02903 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top