I'm currently migrating our Xtext 1.0 projects to Xtext 2.0. As far as I understand in Xtext 2.0 the uris referencing the ecore model from the genmodel must match the uri used within the xtext grammar.
In Xtext 1.0 this worked:
- Create two dsls DslA and DslB
- Add DslA as plugin dependency of DslB
- DslB: Add an 'import "classpath:/../DslA.ecore"'
- DslB: In the workflow, add the referenced genmodel
fragment = ecore.EcoreGeneratorFragment{referencedGenModels = "classpath:/../DslA.genmodel"
In Xtext 2.0 this fails with
The referenced package 'http ://www.mycompany.com/../DslA' was imported from a different location. Here: 'platform:/resource/com.mycompany.../src-gen/../DslA.ecore
The solution is to add an uriMap to the StandaloneSetup of DslB's workflow
uriMap = {
from = "platform:/resource/../src-gen/../DslA.ecore"
to = "classpath:/../DslB.ecore"
}
This was not trivial to figure out, especially cause the error message was masked by some weird invalid super type error (I guess there was some ambiguity) when used in our original projects.
The documentation's section covering classpath imports does not mention this behaviour.
Is this behaviour expected? Why wasn't this a problem with Xtext 1.0