Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » When running genmodel, different developers get different results
When running genmodel, different developers get different results [message #1806475] Thu, 09 May 2019 14:43 Go to next message
David Struck is currently offline David StruckFriend
Messages: 29
Registered: July 2010
Junior Member
I just installed the latest Eclipse. When I run genmodel, I notice that the generated code has several differences from the code generated by other developers on my team. For example:

- StringBuilder is used rather than StringBuffer
- There are more @Override annotations included
- Minor whitespace differences

How do we synchronize our Eclipse setups to avoid these differences? I suppose one option is to have everyone upgrade their EMF plugin to the version that I have. But is there an easier way?

Thanks,

David
Re: When running genmodel, different developers get different results [message #1806478 is a reply to message #1806475] Thu, 09 May 2019 14:57 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Of course it's because different developers have installed different versions of EMF. I.e., the template is now like this:
	public String toString()
	{
		if (eIsProxy()) return super.toString();

		<%=genModel.useGenerics() ? "StringBuilder" : "StringBuffer"%> result = new <%=genModel.useGenerics() ? "StringBuilder" : "StringBuffer"%>(super.toString());
and useGenerics is implemented like this:
  public boolean useGenerics()
  {
    return getComplianceLevel().getValue() >= GenJDKLevel.JDK50;
  }
The template was changed to use StringBuilder when target Java 1.5 or higher by this Bugzilla:

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

Similarly the templates were changed to generate additional @Override annotations when targeting Java 1.6 or higher by this Bugzilla:

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

The best way to avoid this problem would be to create an Oomph setup for your development environment so everyone always has the same one. And so that no one ever wastes time doing menial manual setup.

E.g., look at the simple instructions for setting up EMF's own development environment:

https://ci.eclipse.org/emf/

Basically it's drag and drop and then you go for a short coffee break while your environment is set up.

This was all done using Oomph (which was implemented with EMF):

https://wiki.eclipse.org/Eclipse_Oomph_Authoring


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: When running genmodel, different developers get different results [message #1806479 is a reply to message #1806478] Thu, 09 May 2019 15:24 Go to previous messageGo to next message
David Struck is currently offline David StruckFriend
Messages: 29
Registered: July 2010
Junior Member
Thanks, Ed. Is there a compliance level associated with the EMF plugins that is separate from the compliance level specified in the genmodel file? The genmodel file that we are using has its compliance level explicitly set to 8.0.
Re: When running genmodel, different developers get different results [message #1806487 is a reply to message #1806479] Thu, 09 May 2019 17:36 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
There are only GenModel settings. E.g., Runtime Version for the version of the EMF runtime the generated code should run with. At some point in the future, the templates might be changed to generate code with lambda for Java 8; currently any level higher than 1.6 makes not different. Of course whether to use StringBuilder or StringBuffer in the generated toString method doesn't depend on the EMF runtime, it only depends on whether the version of Java has that class or not. In the end, you should focus on using a consistent (latest?) version of the generator in your development environment, and not on what setting can you set to change the code to generate the same as some older version of EMF.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: When running genmodel, different developers get different results [message #1806496 is a reply to message #1806487] Thu, 09 May 2019 21:55 Go to previous messageGo to next message
David Struck is currently offline David StruckFriend
Messages: 29
Registered: July 2010
Junior Member
Thanks again, Ed.

You say we should use a consistent version of the generator across developers. That sounds smart to me. But what does that entail? Does that mean using the same EMF plugin?

Incidentally, do you have any idea how old a generator would need to be to insert StringBuffer rather than StringBuilder? I imagine it would have to pretty old.
Re: When running genmodel, different developers get different results [message #1806503 is a reply to message #1806496] Fri, 10 May 2019 03:41 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
I gave you a link:

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

And in there you can see the day that is was committed (along the a commit link to see what all changed). And the final comment when the Bugzilla was closed, the comment tells you when a release with this changed was released along with the release name, i.e., EMF 2.14.

And on the update site (also a link in the Bugzilla), the index gives you information about the release, e.g., https://download.eclipse.org/modeling/emf/emf/builds/release/2.14/index.html tells you that this release was built 2018-05-31 at 07:18.



Ed Merks
Professional Support: https://www.macromodeling.com/
Re: When running genmodel, different developers get different results [message #1806505 is a reply to message #1806503] Fri, 10 May 2019 03:48 Go to previous message
David Struck is currently offline David StruckFriend
Messages: 29
Registered: July 2010
Junior Member
Got it. Thanks, Ed.
Previous Topic:How to find if two model elements have the same children?
Next Topic:Cross Reference in Ecore Editor
Goto Forum:
  


Current Time: Sat Apr 27 00:33:36 GMT 2024

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

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

Back to the top