Domanda

I am trying to generate some code using Acceleo. I am constructing my model entity in-memory and I want to generate the code for it.

Now, when Acceleo tries to match my model object to the argument type of my template function, it does not match. The classes are exactly the same, but since the package registry of Acceleo and my in-memory model is different, they do not match and Acceleo says no matching model element could be found for the main template.

Can I correct this issue? Can I force the acceleo package registry to be the in-memory registry? Can I force class matching on a semantic level (instead of just on Java == ? )

È stato utile?

Soluzione 2

To answer this question for anyone who comes along here:

The real issue was the URI of my EMF packages. I had a commons and commons.study package. The URI of the commons package was put as http://domain.com/model.ecore#/. Acceleo adds his own (blank) http://domain.com/model.ecore at runtime, which prevents the proxy resolver from delegating the request to the Workspace.

The solution was to rename my root commons package to the proper http://domain.com/model.ecore and to set the commons.study URI to http://domain.com/model.ecore#//study. This way, the Acceleo resource set will not contain a blank package, and delegates the loading correctly towards the Workspace package registry.

Please also note that your root package needs to be generated. If not, it is not registered correctly and will not be present in the Workspace package registry. So if the root package only contains a subpackage, add a DUMMY class in it as well.

Altri suggerimenti

Acceleo only registers models in its own registry if it can not be found in the global registry. Are you sure you are using the proper NsURI to register the package? The URI you set at the beginning of your Acceleo module ([module myModule('<NsURI>')]) must match the NsURI of your metamodel's root package. It must also match what you define in the registerPackages method of the java class generated alongside your main module (note that since you're creating your model in memory, this last step is probably not mandatory).

If these three match, Acceleo should be able to match the elements of your model with the types defined in the generation module. If it is not sufficient however, we'll need to know how you registered the package prior to creating your in-memory model?

Laurent Goubet Obeo

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top