If you want to make a JAR available in MPS, you have to import it into MPS. I always refer people to this article by Gabriele Tomassetti when this topic comes up.
Today, I want to cover just one aspect of the whole JAR-in-MPS business: the location of the JARs.
A natural inclination is to put them into a subdirectory of your project directory, such as myproject/lib
. This works
but due to experiences with unexpected path shrinking in
MPS I recommend that you put them underneath the directory of the solution.
The path to the JAR is stored in the descriptor (the .msd
file) of the solution that brings it into MPS. If the JAR is
stored under the project directory, MPS will likely store the absolute path or shrink it using a path variable, rather
than storing a relative path that starts with ../
.
Storing the absolute path is unacceptable if the project has to ever be built on a different machine. Storing the path starting from a path variable is slightly better but leads to problems if the path variable is undefined or points to a different copy of the project.
If you put the JARs into a subdirectory of the solution, you avoid all these problems because the path will be stored relative to the solution directory. You can check that it is the case by examining the solution descriptor.
There is one disadvantage: if you keep your JARs out of version control (as you should) and let your build tool (Maven or Gradle) download them, this will make your life harder, as each JAR may have to be placed into a different directory. To help with this, in my Gradle plugin for simplified packaging of MPS plugins I have implemented support for easy definition of dependencies that should be copied to different locations.