How can I import external JARs into my generator project

I have tried it for almost two days now, but I am unable to add a reference to some Spring framework JAR to my generator, so that I could use the Spring classes in my Templates. I tried following the steps I found in several other threads (going to Language Module Properties, add a "java_classes" model root, then go to the "Java" tab, add the Jar there), but no stubs are being generated and I am unable to access the classes. I am using MPS 3.1. If someone could provide me with the steps (possibly with some screenshots) which would allow me to add Java libraries, I'd be very grateful.

Comment actions Permalink
Hi Jan,

this is how it works for me with MPS 3.1.5 on Ubuntu 14.04LTS with OpenJDK:

  1. I create a new Solution only holding the stubs for the external libs
  2. In the Solution properties (alt + enter) I set the following settings:
    • In the common tab click on "add model root", select "javaclasses" and navigate to your lib folder
    • Now select the jar(s) listed on the right of the properties window and click on the blue "Models" button
    • Now switch to the Java tab and add all the jars to the Libraries part of the window via the + on the right sight
  3. A older named "stubs" should appear in your solution
  4. Now you can switch to your generator template of your language and import the classes you need
    • press ctrl + R and type in the name of the class you want to use
    • select the class you need (if multiple classes with the same name exist then check the name of the solution project) and hit enter. MPS will import the class reference and also set the solution as a dependency for the language, if necessary
  5. MPS should now provide auto completion for the class you just imported.

I am sorry that I can not provide any screenshots right now.
Comment actions Permalink
Hi Phillipp,

thank you very much for your reply, it seems to work pretty well this way!


Please sign in to leave a comment.