Bug 406092 - Auto-generated .genmodel file(s) not compatible with org.eclipse.emf.mwe2.ecore.EcoreGenerator
Summary: Auto-generated .genmodel file(s) not compatible with org.eclipse.emf.mwe2.eco...
Status: NEW
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.4.0   Edit
Hardware: PC Windows 8
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-19 09:42 EDT by Chris Ainsley CLA
Modified: 2013-04-19 09:42 EDT (History)
0 users

See Also:


Attachments
Sample project with bug and sample project after workaround. (412.58 KB, application/x-zip-compressed)
2013-04-19 09:42 EDT, Chris Ainsley CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Ainsley CLA 2013-04-19 09:42:31 EDT
Created attachment 229912 [details]
Sample project with bug and sample project after workaround.

Moritz is aware of this I believe but as I noticed that this is not fixed in 2.4.1, I thought I would raise this issue.

The org.eclipse.emf.mwe2.ecore.EcoreGenerator workflow component is used to generate the ecore classes from manually maintained .ecore and .genmodel files.

These files can be manually constructed, or typically, they will be auto-generated by a .xtext file (via the 'generate') keyword, and then at some point, moved from the 'src-gen' folder to the 'src' folder, and at that point the 'generate' keyword is removed from the grammar and replaced with an ecore import.

In order to generate ecore classes from these manually maintained model files (.genmodel and .ecore), then:

1) The following line must be added to the StandAloneSetup bean:

// Example
registerGenModelFile = "platform:/resource/org.xtext.example.mydsl7/src/org/xtext/example/mydsl7/MyDsl7.genmodel"


2) The following workflow item must be added to the MWE2 generator :

        // example genmodel path
	component = org.eclipse.emf.mwe2.ecore.EcoreGenerator {
		genModel = "${runtimeProject}/src/org/xtext/example/mydsl7/MyDsl7.genmodel"
		srcPath = "${runtimeProject}/src"
	}

Now, assuming that NOTHING has been altered from the generated .ecore and .genmodel files, then this should just produce the exact same ECore classes as the 'generate' keyword in the .xtext file (before its removal).

The bug is ... this doesn't work.

Nothing is generated and no error message is shown, except that the rest of the project complains that there are no generated ECore classes.


The fix is (as discovered by Moritz), to manually modify the .genmodel file so that all uri references to the .ecore model are in the platform:/..... format (long name version).

So, the bug has two parts.

1) To either auto-generate .genmodel files with the full platform:/ or namespaced version of the ecore model.
2) To display an error message if the ecore referenced in the genmodel file are not in the correct format.

Currently, this is failing silently, and is difficult to diagnose (Moritz diagnosed this).

I raise this issue just as a reminder that this should be fixed, and to provide a concrete example.


Notes on attachment:

In the attached file, project 1 contains the default XText greeting project, that had its MWE2 generator executed once, then the .genmodel and .ecore files copied from src-gen to src folders. The .xtext file was modified to remove the 'generate' keyword and an import added. The MWE2 file was modified to add the ECoreGenerator item (plus the genmodel declaration earlier). The MWE2 file was then executed again and no ECore classes pertaining to the greetings module were generated (the project has errors relating to lack of ECore generated classes).

Project 2 is identical to project 1, but the .genmodel was manually corrected to add the platform prefix, then MWE2 executed, and the classes are now generated and everything is working.

There is also a folder containing the .genmodel files alone (before and after), as well as a PNG of a partial diff.


Items to be fixed:

1) Please fix the ECoreGenerator so that it throws an error/warning when generating no classes and this should include a narrative to the expected format or formats of the ecore definitions. Failing silently is evil. :)

2) If the generated .genmodel (via the 'generate' keyword in an .xtext file) is incorrect, then please fix this. Users should be able to just copy the generated .genmodel to the src folder, add in the ECoreGenerator item, and it should just work.

.... thats it.