Best practices for using Java libs
Hi,
I know I can include in my MPS Projects jars:
1) Including them as design time or runtime libraries in the module
2) and then adding the corresponding stub into the imported modules of the model where I want to use those classes.
I have two problems with that:
Thank you!
I know I can include in my MPS Projects jars:
1) Including them as design time or runtime libraries in the module
2) and then adding the corresponding stub into the imported modules of the model where I want to use those classes.
I have two problems with that:
- the path to the jar is recorded as absolute: is it possible to use relative paths so that I can develop the same Project from different machines?
- when I need to update the Jar how can I reload it? I was about to delete the jar from the list of used stubs but MPS alerted me that all the references would be lost. What are the alternatives?
Thank you!
Please sign in to leave a comment.
The relative path will be stored if and only if you have your jar-file located inside of the directory, which contains the module that uses this jar-file. If you have many modules importing the same file, only one of them will store a relative path (but I strongly do not recommend importing the same library twice as this can cause problems in future as you'll have many instances of the "same" models; better import the lib into a separate module and add a module dependency on it where needed)
In MPS 2.0.x, you need to restart MPS. You an also try the Tools->Reload all classes from main menu, but this won't load _new_ models from jar file, only update existing. This is a bad thing about 2.0, but that's what we have.
In forthcoming 3.0, which we plan to release in a month or two, we've nearly completely rewritten the stubs subsystem, so now there's no difference between stub models and regular MPS models - the reload/update process is absolutely the same, so to update jar, you just replace it on disk, and move focus to MPS window - models will be updated automatically. The same thing is with relative paths. You will just be adding stub models in the same list with regular models.
Regards,
Mihail
it is great to read that MPS 3.0 is coming in a few months!
I did not manage to have the relative path. I have the MPSProject located in "D:\Repo\mps\".
The directory contains the subdirectory "languages" and "solutions". I want to use inside the language "MpsPluginExample".
I tried placing the jar in:
but when I include it (Module properties, Design Time, Libraries) I still see the absolute path.
Federico