How to set the order of the mapping configurations?
I am currently trying to create a simple Entity-To-View converter. The idea is to have a custom object "Entity" and another custom object "View" and generate the JPA entity a view object and a converter between these two with MPS. So i have set up a generator which contains (among other things) two mappings:
One which converts the "View" into a java class (called "views") and another which converts the "View" into a converter java class (called "converters"). Now since the converter requires the view, i want the "converters" mapping to run after the "views" mapping so that I can use mapping labels to get the generated view class.
I tried to set this up in the "Generator Priorities" (as shown here: https://confluence.jetbrains.com/display/MPSD30/Generator+User+Guide+Demo6#GeneratorUserGuideDemo6-specifyingpriorities) but once I set that priority, the "converters" mapping configuration is no longer executed anymore and therefore no converter is being generated.
I am probably setting something up the wrong way. Can someone help me in setting this dependency up correctly?
One which converts the "View" into a java class (called "views") and another which converts the "View" into a converter java class (called "converters"). Now since the converter requires the view, i want the "converters" mapping to run after the "views" mapping so that I can use mapping labels to get the generated view class.
I tried to set this up in the "Generator Priorities" (as shown here: https://confluence.jetbrains.com/display/MPSD30/Generator+User+Guide+Demo6#GeneratorUserGuideDemo6-specifyingpriorities) but once I set that priority, the "converters" mapping configuration is no longer executed anymore and therefore no converter is being generated.
I am probably setting something up the wrong way. Can someone help me in setting this dependency up correctly?
Please sign in to leave a comment.

You may try the "Show Generation Plan" option in model's context menu to see the plan that the generation has built.
BTW, the link to the doc points to an MPS 3.0 version. Not that there have been so many changes, but https://confluence.jetbrains.com/display/MPSD30/Generator+User+Guide+Demo6#GeneratorUserGuideDemo6-specifyingpriorities would be safer.
With the "keep input roots" enabled, generation now goes a bit further but I am getting strange error messages that the context node for my one weaving template could not be defined. Is there some way to debug all the scripts that you enter, so you can basically see what kind of node a script is currently working on and what it is returning?
Some more details are to be found here: https://confluence.jetbrains.com/display/MPSD32/Generator+cookbook#Generatorcookbook-CanIdebugthegenerationprocess%3F
The generation plan shows the names and order of all generators that will be run when generating the selected model.
and
However in the final output only the references to the Agent class are resolved but not the references to the AgentView class.
This leads to compilation errors further down the road. Are mapping labels only valid within the same generator phase? If so, how can I reference stuff that has been generated in an earlier phase?
indeed, mapping configurations are not visible across different generation steps.
Is there anything that prevents you from joining the two phases into one, maybe even a single mapping configuration with two (or more) root mapping rules? The reference macros should be processed correctly only after all classes have been generated and added to mapping labels.
Vaclav
it seems that I fundamentally misunderstood the way in which root mapping rules work. I thought that once a root mapping rule processed an input element, that input element will not be processed by another root mapping rule. Therefore I thought that you cannot have two root mapping rules which use the same concept as input. And that's why I came up with multiple mapping configurations when I in fact don't even need them. I just tried adding multiple root mappings and it indeed solves my problem :) Thank you very much for this eye-opener.
Jan
>Is there anything that prevents you from joining the two phases into one, maybe even a single mapping configuration with two (or more) root mapping rules?
Vaclav,
I've got similar problem and I tried to reuse mapping labels from one mapping configuration in subsequent one. It looks like mapping labels are not accessible in between mapping configurations. Are there ways to workaround that except merging all the configs into single mapping config? (I use multiple languages so it is not quite possible to use single mapping configuration)
By the way, multiple mapping configurations produce multiple transient models, so they make it easier to debug the generation.
I believe the mapping configurations need to be run in the same phase of generation (and the model with the labels has to be imported in the other generator model).
I could add that running mapping configurations in the same generation step is achieved either by generator priorities (generator module properties dialog, priorities tab) which is the old method, or with the help of a new feature https://confluence.jetbrains.com/display/MPSD34/Generation+plan