Bug 521250 - Source eCore file is read from plugin instead of workspace
Summary: Source eCore file is read from plugin instead of workspace
Status: NEW
Alias: None
Product: Acceleo
Classification: Modeling
Component: Core (show other bugs)
Version: 3.5.0   Edit
Hardware: PC Windows 7
: P3 normal
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2017-08-22 08:30 EDT by Eric Lépicier CLA
Modified: 2017-09-25 03:25 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Lépicier CLA 2017-08-22 08:30:32 EDT
Hi,

I'm producing code from an ecore source model which is in a workspace project. This project has been imported from a platform plugin (the metamodel was deployed). The transformation and its ui are executed in a runtime eclipse platform. The strange thing is that the generator doesn't see the changes I make on the source ecore file.

The I ran the thing in debug mode and discovered the origin of the problem.

The AbstractAcceleoGenerator::initialize method uses a URIConverter, created by the method createURIConverter and given to the ResourceSet. When loading the source model, this URIConverter converts my platform URI to a plugin URI and the source of the generator becomes the ecore file contained in the plugin.

I tried to override the createURIConverter to get rid of this behavior, but unfortunately, the same instance is also used for the emtl module loading, which fails with a classic URIConverter.

I've finally been forced to override the whole initialize method, copying and patching its code in my main generated java file. I simply commented the modelResourceSet.setURIConverter(uriConverter) line.

Did I missed sth ?
What is the need to convert the source model URI ?
Could it be simpler than recoding the whole initialize method ?

Cheers
--Eric
Comment 1 Laurent Goubet CLA 2017-09-11 05:14:52 EDT
We advise not to have the metamodel in the same workspace as it causes adverse effects such as what you're experiencing. These problems originate from the pre-luna versions when Acceleo generations could be started from the same workspace as they were developped in, so there could be ways to avoid these limitations now... 

Instead of overriding the whole initialize method, I suggest you override the "createURIConverter" method to return your own, or null.
Comment 2 Eric Lépicier CLA 2017-09-11 06:00:46 EDT
Laurent,

I understand the advice, but in my case, the ecore metamodel is the source model of my M2T transformation ... And I can't remove it from the platform when getting it in the workspace.

As I said, it was my first approach to override the createURIConverter method, giving it a null result.
The problem is then that this URIConverter is used both for source model and module loading. When null, the module loading fails.

I would suggest you to use two different URIConverter, one for the source model which could be overridden in a simple way by user code (createURIConverter method), and another specific one to keep mastering the .emtl loading.

That's what I implemented : commenting the modelResourceSet.setURIConverter(uriConverter) line is like letting it null), the pity is to be forced to copy the whole complicated initialize method.
Comment 3 Laurent Goubet CLA 2017-09-11 09:39:15 EDT
It doesn't cost much to add a new protected "ceate*URIConverter" method that users can override but that will by default delegate to the existing "createURIConverter" one I guess. Can keep this in mind for the next version.
Comment 4 Eric Lépicier CLA 2017-09-11 09:50:48 EDT
That would be nice, keeping compatibility and offering a clean way to customize ;-)