Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EcoreGen] State-of-the-art way to generate code from Ecore in Maven?
[EcoreGen] State-of-the-art way to generate code from Ecore in Maven? [message #1796398] Fri, 12 October 2018 11:29 Go to next message
Niko Stotz is currently offline Niko StotzFriend
Messages: 8
Registered: June 2010
Junior Member
Hi all,

I'm working on a product with several projects, each containing one ecore model. These models depend on one another (without circles). Within Eclipse, I can generate the code by manually running the generator on each genModel.

However, automating this using Maven has proven to be a challenge.

I've found multiple posts that are closely related to my problem, such as:

https://www.eclipse.org/forums/index.php/t/202345/, a post describing to use an Ant task.

I've also come across mentions of running a headless eclipse version to generate the required code, but no clear documentation on how to get started with that.

Since the posts I found are from ~2010 or earlier, my question is as follows: is that Ant task (or the headless eclipse solution) still the preferred solution, or is there something newer that I've missed? Might an MWE2 workflow be helpful?

Thanks a lot.
Re: [EcoreGen] State-of-the-art way to generate code from Ecore in Maven? [message #1796400 is a reply to message #1796398] Fri, 12 October 2018 12:13 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Yes. I use an MWE2 workflow for all (nearly 20) OCL and QVTd models. MWE2 is good. Don't use Ant.

See http://git.eclipse.org/c/ocl/org.eclipse.ocl.git/tree/examples/org.eclipse.ocl.examples.build/src/org/eclipse/ocl/examples/build/GenerateCGModels.mwe2 for a comparatively simple script.

NB. I keep all the scripts in a separate build plugin to avoid polluting production plugins with redundant build dependencies that can contribute to build cycles and consequently long build times.

I prefer to invoke scripts manually from launches since I want generated Java to be committed to GIT for ease of use by simple checkout. Also I am dubious of the benefits of uncontrolled regeneration whenever tools evolve. e.g. first milestones of a next Xtext quite often throw up a compatibility issue. Xtext does not provide the required forward AND backward compatibility necessary to guarantee compatibility of newly generated editors by old platforms. EMF does, provided you select a low runtime compatibility.

Regards

Ed Willink
Re: [EcoreGen] State-of-the-art way to generate code from Ecore in Maven? [message #1796487 is a reply to message #1796400] Mon, 15 October 2018 08:25 Go to previous messageGo to next message
Jan Jansen is currently offline Jan JansenFriend
Messages: 17
Registered: October 2018
Junior Member
Hi Ed,

Thank you for your thorough answer!

If I read and understand the script correctly, I'd have to write my own variant of the EcoreGenModelSetup/GenerateModel classes as necessary for the project(s)?

Regards,

Jan

Edit:

I've actually got it working with the following workflow:

Workflow {
    bean = org.eclipse.xtext.ecore.EcoreSupport {}
	
    bean = ResourceSetImpl : resourceSet {}
    bean = StandaloneSetup { resourceSet = resourceSet
    	platformUri = "${rootPath}"
    	scanClassPath = true
    }
    
    component = org.eclipse.emf.mwe2.ecore.EcoreGenerator {
		genModel = "platform:/resource/${projectName}/model/ModelName.genmodel"
		srcPath = "platform:/resource/${projectName}/emf-gen"
	}
}


Thanks again Ed!

[Updated on: Mon, 15 October 2018 09:07]

Report message to a moderator

Re: [EcoreGen] State-of-the-art way to generate code from Ecore in Maven? [message #1796727 is a reply to message #1796487] Thu, 18 October 2018 07:48 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Thanks for bringing the 'new' MWE2 classes to my attention. I've raised

https://bugs.eclipse.org/bugs/show_bug.cgi?id=540239

to try and bring the best of both worlds together.

Regards

Ed Willink
Previous Topic:Modern automated code generation from ecore model
Next Topic:[CDO] How does CDOResourceNode.setFolder(...) work?
Goto Forum:
  


Current Time: Thu Apr 25 15:30:54 GMT 2024

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

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

Back to the top