Separate MPS caches for different MPS distributions based on the same MPS major version

Between MPS major versions, the MPS global caches are nicely separated (e.g. for MPS 2017.1, the cache directory is $HOME/.MPS2017.1 and for MPS 2017.2, the cache directory is $HOME/.MPS2017.2, where $HOME is your home directory, e.g. C:\Users\<yourusername> on Windows or /home/<yourusername> on Linux). Sometimes, there are reasons why you would want to change the cache for a specific MPS distribution on your filesystem. Some of these reasons are:

  • Run different distributions or RCPs of MPS that have the same major version at the same time on your machine
  • Separate two MPS global caches (e.g. a cache for production in some project you work on and another cache for a course you have to give tomorrow), so they don’t interfere with each other.
  • Be able to open two modules (language or solution) with the same name/ID, without the two getting intermixed in the global cache (or MPS thinking that one has already been loaded, making the other read-only).

By default, the MPS cache-directory for an MPS major version called <version> (located under your $HOME directory) is .MPS<version>, e.g.: .MPS2017.2.

You can change this default location by adding a line like this in your vmoptions (for Windows, it’s located under your <mps installdir>\bin\mps64.exe.vmoptions):


This would lead to the MPS that you run from <mps installdir> to maintain a cache directory called .MPS-MYOWNTHING in your $HOME directory.


How I make an open source mbeddr developer release

The mbeddr RCP is great, because it gives you a focused MPS-based IDE, including mbeddr.platform, which you can use to write models in the embedded software domain.

However, I find it often useful to have the mbeddr.platform plugins (which are generic pieces of functionality useful for any DSL development) available for development as a language engineer, not as someone who wants to write mbeddr models.

If you want the full-blown mbeddr development environment (which requires you to do a build of the entire mbeddr.platform and mbeddr DSL stack), just follow the mbeddr build environment setup howto.

However, I often have the use case where I just quickly want to setup an MPS distribution (e.g. for student courses or student projects) with the mbeddr DSLs included. In this case I just perform an easy procedure:

  • Look on the mbeddr.core github releases page for the latest nightly build
  • Determine which MPS major and minor versions are used by the latest nightly build:
    • For a specific release on the releases page, download the source code (e.g. zip file)
    • Look in the upper subdirectory of the zip for the file called build.gradle. There is a line in this file that starts with ext.mpsBuild =, e.g.: ext.mpsBuild = “2017.3.4”. The version number is the specific MPS build that this mbeddr nightly is using.
    • In the same build.gradle file, there is a line that starts with ext.mpsMajor =, e.g. ext.mpsMajor = “2017.3”. This is the MPS major version used.
  • Download the unified package (zip-file) of the MPS version you found in build.gradle. Currently the MPS download links are nicely formatted like this:<mpsMajor>/MPS-<mpsBuild>.zip.
    So, e.g. for MPS 2017.3.4 you can manually construct the download URL (which will be and then use your favorite download tool (e.g. wget or your browser) to download it.
  • From the mbeddr releases page, download, depending on what you need:
    • (full mbeddr distribution including mbeddr.platform and embedded development DSLs)
    • (mbeddr.platform only).
  • Unzip the MPS zip (extract here, this will create a subfolder called MPS <mpsMajor>, e.g. MPS 2017.3) and then unzip the chosen mbeddr zip (either or into the MPS folder (which places all the mbeddr plugins into the plugins subdirectory of your MPS folder).
  • Inside your MPS folder, copy all the files from bin/<platform> (where <platform> is the platform you work on: win, Linux, or mac) one directory up (so the executables for your platform end up in the bin directory).
  • Either set a command line variable called MPS_JDK which points to your Java JDK installation, or edit your relevant launcher file (e.g. for Windows this is bin/mps.bat) and locate the line where JDK= is set and put your JDK path there).

Additional info on 25 July 2018: JetBrains nowadays uses a self-maintained JDK for MPS. So far I haven’t been able to find it on the JetBrains site, but Itemis provides downloads of these JDKs for all three platforms (Linux, Windows, Mac) at, e.g.:

Additional info on 29 July 2018: Instead of unzipping mbeddr plugins into MPS, you can also just install a native version of MPS (using setup.exe or the Linux or Mac installation package) and then use global libraries to point to the mbeddr plugins:

Language Visualization Plugin for JetBrains MPS

We just finished migrating the language visualization plugin to MPS 2017.3.

This extension can visualize the structure of a language graphically, in order to give insight for new people learning a language, and to save effort in creating diagrams of a language.

You will need PlantUML to make a picture of the language visualization. The visualization will be saved as mps-metamodel.txt in your home directory. Easiest is just to start PlantUML, let it point to mps-metamodel.txt, and after every visualization command, you will see the updated picture in PlantUML. Please see for more information.

Using the extension can be done in two ways (we use the Entities language ( as an example):

  1. Right-click the structure of a language and choose → Visualize Language Structure (you might need to scroll down a bit if you have mbeddr plugins installed, as there are quite some items in the pop-up menu after you right-click):


which will lead to a picture like this, when we open it in PlantUML:


  • Right-click a concept in a language’s structure and choose → Visualize Concept Context:

which will lead to a picture like this:



How to debug in MPS

The quickest way to start debugging in MPS is the following:

We are using com.dslfoundry.plaintextgen as an example.

Please be advised that in (possibly earlier) generic distribution versions of MPS, the debugger doesn’t work. You will have to really use one of the dedicated distributions (Mac, Linux, or Windows).

  • Choose your breakpoint by clicking in the gutter:


  • Select Run –> Edit Configurations from the main menu:


  • Press + to choose from the list of new configuration types to add:


  • Choose MPS –> MPS Instance:


  • Check Open current project:


  • Type your own name for the run configuration (I chose MPSInstance):


  • Press OK to close the Run configuration screen and then select Run –> Debug MPSInstance from the main menu:


Now a second instance of MPS will be started (click away all the startup screens that come in).

With the given breakpoint, let’s inspect variables:

  • Trigger the code with the breakpoint by executing the Surround with Horizontal Collection intention:mps-debugging-8
  • Now the MPS instance is going to freeze, because the debugger paused it at the breakpoint. Go back to the original MPS window from where you started the debug session and view variables:mps-debugging-9

Tip: enable toolbar for having convenient debug buttons. You can do this by selecting View –> Toolbar from the main menu.

How to build mbeddr on Windows

This howto describes how to build the mbeddr sources from scratch on Windows.

If you are looking on how to build an mbeddr or mbeddr platform-based app, please see the mbeddr build guide.

In this howto, I built mbeddr nightly 380 for JetBrains MPS 3.4.3 on Windows 7 using Oracle JDK 1.8 update 121 (see the JDK Oracle archive if the link is not available anymore), ant 1.9.7, and mingw32 (also install msys along with it and select the pthreads dev package).

A warning to those who want to use OpenJDK instead of Oracle JDK: the mbeddr build uses gradle, which needs keys for the gradle and mbeddr service repositories in the trust store. You can try this solution to add the necessary keys from the servers in the URLs of gradle and mbeddr that go wrong, but I chose the easy route and used Oracle JDK, which is anyway recommended with JetBrains MPS, the platform on which mbeddr is built.

Start first by checking out the mbeddr.core repository and checking out the nightly-380 tag:

> git clone
> cd mbeddr.core
> git checkout nightly-380-MPS-3.4.3

Before starting to build, don’t forget to put javacant, gcc, and make in your PATH and all the java platform jars in your CLASSPATH, either in your global/local environment variables, or directly on the shell before compiling. I did it on the shell:

> set PATH="C:\Program Files\Java\jdk1.8.0_121\bin";%PATH%
> set PATH=C:\app\apache-ant-1.9.7\bin;%PATH%
> set PATH=C:\app\mingw32\bin;C:\app\mingw32\msys\1.0\bin;%PATH%
> set CLASSPATH="C:\Program Files\Java\jdk1.8.0_121\lib\*.jar";%CLASSPATH%

Then you only need to tell gradle to do its job:

> gradlew build assemble

If you also need to use your locally built version of mbeddr for other builds on your local machine that depend on it, you can run this command to put it in the local Maven cache:

> gradlew publishMbeddrPlatformPublicationToMavenLocal

Thanks to  Sergej Koščejev and Kolja Dummann from the mbeddr team for the hints and tips to get the build running.

How to write a dump of an MPS model to XML based on its structure

This post has been written using material developed in JetBrains MPS 3.3.5. The example project can be found at DSLFoundry’s MPS example github repository under StructureDumpToXML. It is recommended to have this project opened while going through this howto.

Suppose you want to dump a model to some simple XML format without wanting to write a generator or wanting any specific knowledge about the structure of the model. A use case for this could be that you don’t want to have to make changes in the generator for a simple XML dump, just because you change the structure. Now of course this can be solved using custom persistance, but let’s say you just want something quick and simple without having to deal with too much of the more complicated stuff like references. This howto shows such a simple case. So here we go:

An example model:


Let’s use the generator mechanism and the xml language from JetBrains to make an XML dump out of this:

  • make a root mapping rule, by double clicking on the generator’s main, then click on root mapping rules and press enter:


  • choose MyConcept in the input concept:


  • import the xml language by pressing Ctrl+L+L (yes, you have to press L a second time) and then choosing it:


  • stand on the template of the root mapping rule and press Alt+Enter to invoke the intention menu and choose New Root Template, then choose directly xml file:

2016-10-27-13_04_43-structuredumptoxml-d__repo_dslfoundry_mps-examples_structuredumptoxml-_ and then:


  • navigate to map_MyConcept by Ctrl + clicking it:


  • add an XML element using the completion menu:


  • call the element something (e.g. bla) and create a MAP_SRC macro which makes it possible to build any wild mapping construct you’d like:

2016-10-27-14_34_45-structuredumptoxml-d__repo_dslfoundry_mps-examples_structuredumptoxml-_ and then:


  • now go to the inspector of this MAP_SRC macro by clicking the macro and pressing ALT+2:


  • go to the <none> part of the mapping func and then press Enter to create a mapping function:


  • from this point on, you can type baseLanguage code, which is pretty much the same as typing java. We replace the XML element <bla></bla> with a new XmlElement node that we create, using some regular programming. See the next step first to see how to create the dumpStructure funciton so that you can call it here in the macro. The code you see is a combination of baseLanguage and smodel language. The MPS smodel language makes it possible to query a model and build nodes. For more information on this, see the MPS smodel reference:


  • in the above piece of code, we use a piece of behavior that belongs to a helper aspect called StructureDumper. This code can be created by making a concept called structure helper and then making a new behavior for it:


  • now we can type the code for the dumpStructure function. This is just a recursive function reading the model and dumping everything to XML. Note: in the statement mpsNode/.getProperties(), there is this strange notation mpsNode/. This is a so-called semantic downcast operation. It makes it possible to reach directly the java class that encode the node mpsNode (needed here for reflectively reaching its properties).


  • since the XML language has a text generator and we hooked the transformation from our model to XML in a MAP_SRC macro of a generator, we have text generation. You can preview the text by right-clicking the model called myconcept in the StructureDumpToXML solution and selecting Preview Generated Text:


  • and the text will look like this:


  • note that nothing smart has been done yet with references. This is tricky, since we may get (even indirect) circular references.

This howto has demonstrated the use of MAP_SRC macro to do a dump of an arbitrary (at least for simple cases where it’s a tree) MPS model to an XML format of your own choosing. Feel free to extend and improve for your own needs. We may one day make a language that will just do this automatically.

If this post helped you, gave you ideas or has motivated you to help, please feel free to contact us on github.

Extra tips:

  • if you need special characters properly escaped as XML entities in MPS 3.3.5, it is recommended to use mbeddr’s com.mbeddr.mpsutil.xml.fix language.
  • you may need to use light quotations instead of the manually written code for node instantiations in the above described dump function (see JetBrains docsite on light quotations). The reason that you cannot use full quotations is, I think, because you may not have all the editors built before building behavior, which makes it impossible to have the editor to make a full quotation.

How to add default to a property in a concept

This post assumes that you have an MPS with mbeddr preloaded.

Go to the constraints aspect for the concept you want to add a default to a property:


Create a new constraint for this concept:


Press Ctrl+L and import the language com.mbeddr.mpsutil.propertydefault:



Go to the property constraints and press Enter to make a new one:


Choose the property to which you want to apply a default value:


Select the entire constraint by pressing ctrl + uparrow twice:


Press Ctrl + Space and choose default to convert the constraint to a default specification:


Choose your default value:


If you now make an instance of MyConcept, you will automatically get the myProperty filled in with the default value:



First pre-release of mps-textgen-multilanguage plugin

This plugin enables you to use the standard template mechanism of MPS (node macros, loop macros, property macros, etc.) to generate free text. So if you have some custom text format you want to generate to, you will have a more easy and useful mechanism than the standard MPS textgen.

Please see the mps-textgen-multilanguage github page for more details.

Download: mps-textgen-multilanguage first release tag.

Where are mbeddr builds located?

Go to the mbeddr build page.

Login as guest (username: “guest”, password: “guest”) and then go to Build –> the plugin you want to download (e.g. sl-all) –> branch you want to download from.

Then choose Latest successful build –> Artifacts –> Download all (zip)

See picture below for the example of the sl-all plugin