Hi. I have packaged a set of jars in an MPS plugin, so that I can have them available as stubs in a nice scoped way (Similar to the JDK). The language in which I use the classes from the jars compile ...
This is an auto-generated question from the MPS Slack community: Hi. I have packaged a set of jars in an MPS plugin, so that I can have them available as stubs in a nice scoped way (Similar to the JDK). The language in which I use the classes from the jars compile just fine. However, at generation time I get the following error at the generated import statements that refer to my java packages:
`package <my package> does not exist (C:snaplanguagesmy-languagesource_genMyClass.java:123)`
I did include the jars themselves in the zip layout of the build model of the plugin.
Any ideas what I might have forgotten / how to solve this?
10 comments
Sort by
Date
Votes
You probably need to add the containing solution to the list of language runtimes in the language properties
Thanks, Sergej, but that doesn't help unfortunately. I think the problem lies with how I wrap the jars and/or its corresponding build solution.
There are so many details that can go wrong:
• where do I put my jars? under the solution, outside?
• add jars as model root to solution? also as lib in java facet?
• how to correctly deploy the jars in the zip in the build solution?
If you know of a primer on how to create a solution to deploy stubs, that'd be most welcome.
a href='https://github.com/DSLFoundry/mps-javafx'Here/a you can find my failed attempt, might you be interested.
Slack user:U025QJQK0KG> the project builds just fine for me, how can I reproduce the error?
Sorry, I was working on it right now and I just checked in a new version which indeed builds fine.
I suspect I solved it... the jars should be in a folder 'lib' under the solution itself.
(Source: https://github.com/specificlanguages/mps-gradle-plugin/blob/master/README.md)
This makes MPS use relative referencing (from the module) as opposed to encode a hard path to the jars in the plugin files. The zip that deploys the plugin should reflect that same 'relative structure' (i.e. folder lib with jars) and the jar files should be mentioned explicitly in the build model. So far so good.
Using the plugin to trigger some javafx code in a language (e.g. show JFXPanel in some util class triggered by an intention) that works fine now, too.
The problem I faced yesterday is when you use that language in a client solution project, then triggering the same intention from the model goes wrong. All kinds of weird java errors. At least it went wrong yesterday. Maybe my changes with the lib folder fixed it. Currently building all stuff. Then I can test again. Keep you posted.
Yes, I recommend you put them under the solution. Just wrote a post on this: https://specificlanguages.com/posts/2022-03/04-where-do-i-put-my-jars/
But I don't think the structure of the zip package has to reflect the structure of the sources. I believe MPS will handle different structure properly and will generate the correct module descriptor for the packaged module (different from the one of the source module).
I only I knew this earlier.. I found out the hard way :slightly_smiling_face:
Slack user:U6JDVSG3S Slack user:U6K3FGW3U Thanks for your articles on this topic. I've referenced them in the README from a href='https://github.com/DSLFoundry/mps-javafx'here/a, which is a nice application of this jar-techniques.
Thank you for referencing the article!
Thank you!
This is auto-generated question from the MPS Community Slack Workspace. If you want to comment on the question, do it from the Slack workspace
Post is closed for comments.