Language build and code generation in CI/CD pipeline.

I'm an MPS newbie. We're trying to use MPS in our internal process to define a language that will help us to define tests in a simple way and generate boilerplate Java code out of those definitions. It works great in the IDE (define language, editors, write models, rebuild all, generate code) but we would like to have build and generation steps executed also as part of the CI/CD pipeline. One sentence summary would be that we want to define the language, models in IDE, commit it to the repository, and during the build pipeline rebuild language, generate java code from models, and use generated code as part of our product build. 

The "extra" steps in the regular CI/CD pipeline would be:
1) check out a project with "our" language and models defined in this language,
2) rebuild the language,
3) generate java code based on the models
4) use generated classes as part of the "regular" product build.

I cannot find a clear answer in the documentation or in the existing posts on how to achieve 2) and 3). Can you please advise on it or point to the proper documentation and examples? What is required to be installed to have it run on a server - "headless"?

The version is MPS 2021.3

Thanks a lot in advance for your help.

Comment actions Permalink

The build language is meant to help you do this -

Comment actions Permalink

Hi Jaroslaw,

As Václav wrote, the build language will help you with 2 and 3. The build language will generate an Ant file that you will need to check in to source control. You will need to provide Ant with an MPS installation and any dependencies your project needs. MPS-based projects usually solve this by setting up a Gradle or Maven build script that downloads MPS and dependencies and then calls out to Ant. I have written about it in more detail here: - at the end of the article you will find links to example Maven and Gradle build scripts.

Comment actions Permalink

Vaclav and Sergej, thanks a lot for your prompt replies. In the meantime, I managed to come to the same conclusions by "trial and error approach" and it seems working nicely indeed. Sergej, the article you linked here is exactly, what I was initially looking for and I believe it will be super useful for anyone looking for a similar solution in the future. Thanks once again.


Please sign in to leave a comment.