I have released a new major version of my Gradle plugin for building MPS projects from Gradle, com.specificlanguages.mps, or specificlanguages/mps-gradle-plugin. The plugin is available from the Gradle plugin portal.

In this new version I have incorporated all the experience I got from setting up builds of MPS projects for customers. Version 1 of the plugin relied heavily on conventions, but I quickly found that, while the idea is compelling, conventions can only work for very simple projects at present.

Therefore, in the new version the build author has to specify the structure of their project explicitly. In exchange, the plugin now supports multiple MPS build scripts, including tests, and even having multiple MPS projects built from a single Gradle project.

Why use the MPS Gradle plugin? There are two main reasons, describing the builds on a higher level of abstraction and staying up to date with the current Gradle best practices for writing build scripts. Writing build scripts on a higher level helps with their maintenance, and Gradle rewards well-written scripts with performance optimizations.

Many build scripts of MPS projects were cobbled together by copying existing scripts from other projects without giving much thought to abstractions. This is mainly because the build scripts were quite complicated to begin with, but this became a vicious cycle with the copied build scripts becoming even more complicated and more and more difficult to maintain over time.

With mps-gradle-plugin, you list the build scripts and their dependencies, and the plugin registers the necessary Gradle tasks. The tasks that the plugin registers are more granular than what build authors would write themselves. This helps potentially avoid more work and have builds complete faster.

Using modern Gradle practices such as lazy configuration and configuration avoidance improves build performance further by avoiding unnecessary work. In addition, although not implemented yet, lazy configuration will enable build and configuration caching, potentially further improving build performance for complex projects.

And there are some convenience features as well. The plugin will:

  • generate build scripts for you, so you don’t need to maintain a separate ‘build all scripts’ build script,
  • cache MPS and JBR for all subprojects within a single project, and optionally across multiple unrelated projects, so that you don’t have a dozen separate copies of MPS lying around,
  • configure MPS to put its cache and log directories in different locations for different tasks so that several MPS instances can run in parallel without stepping on each other.

The new version is already in use in the build of MPS-extensions and I encourage you to try it out on your projects.