Error "cannot find used devkit in dependencies: jetbrains.mps.devkit.language-design" when creating a build script for a solution

Hi,

I've been trying to create a simple build script that would build a simple solution for a simple language. However the dependency system totally eludes me and I keep getting errors that I simply cannot make sense of. I already read Getting the dependencies right, but it just explains the dialogs without getting into much detail on why you actually need 4 types of dependencies and into which of the 4 dialogs you have to put your dependencies on which occasion (let alone the fact that you have dependencies on the module and the solution level which seem to be related to each other).

So here's what I did so far. I created a "Hello World" language which just has one concept and builds a java "Hello World" from it. Then I created a "Test" solution which just creates an instance of the one concept of my "Hello World" language. Finally I added a "Hello World.build" project, where I wanted to create a build script for the test module, so I can build a sample hello world from the command line with ant.

structure.jpg



Now in the language itself I have the following dependencies set up:

common_tab_for_hello_world_language.jpg

dependencies_hello_world_language.jpg


So far, this looks like I would expect it. I am using the language-design language, so I put it into language dependencies. When I build the "Hello World" language, everything works well. So now I added my "Test" solution. This has the following dependencies set up:

common_tab_for_test_solution.jpg

used_languages_for_test_solution.jpg


This seems to work for creating instances of my "Hello World" concept and for generating previews of the generated text. But when I build that "Test" solution, I get the following list of errors:

testmodel/MyWorld.java : The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files (line: 1)
testmodel/MyWorld.java : Implicit super constructor Object() is undefined for default constructor. Must define an explicit constructor (line: 6)
testmodel/MyWorld.java : String cannot be resolved to a type (line: 7)
testmodel/MyWorld.java : System cannot be resolved (line: 8)
compilation finished : errors: 5 warnings: 0
Compilation problems
testmodel/MyWorld.java : The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files (line: 1)
testmodel/MyWorld.java : The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files (line: 1)
testmodel/MyWorld.java : Implicit super constructor Object() is undefined for default constructor. Must define an explicit constructor (line: 6)
testmodel/MyWorld.java : String cannot be resolved to a type (line: 7)
testmodel/MyWorld.java : System cannot be resolved (line: 8)

prettyPrint();

Now that is strange. I included my language into Used Languages and previewing the text works as well, but when I build I get errors. After some trying around I could make the error go away by adding the "Hello World" language to the "Dependencies" tab in addition to adding it to the "Used Languages" tab:

dependencies_for_solution.jpg


This is already confusing me. I added the language to "Used Language". Why do I need to add it to "Dependencies" as well?  If I use a language it's implicitely a dependency. And even more confusing is, that when using the "jetbrains.mps.devkit.language-design" language in the "Hello World" language  I don't need to add this to the "Dependencies" tab of the language and it still works. So, well, that issue solved, moving over to the build script. I created a simple build solution with the wizard, removed the generated file for the IDEA plugin (as I just want to build that "Test" solution and don't want to create an IDEA plugin). Then I added a new build script from scratch following the instructions given in "Build Language".

exceptions_in_build_module.jpg


So I just changed the path to be the root of my project, and then added the mps plugin and a mps group with my solution. This yielded an error "dependency on a module not visible from current build project". So i thought, okay, maybe I need to add the language as well and I did it. This yielded another error "dependencies should be extracted into build script".

dependencies_should_be_extracted.jpg


So i quick-fixed it with "load required information from file".  Now the build file doesn't have any more red parts, but when I build the project I am greeted by another load of dependency errors:

errors_when_building.jpg



And this is where I hit the wall. I have no idea why I am getting these errors and where I would specify each of these dependencies. There seem to be various options:

  • In the language module (but it works without them, so why specify them there?)
  • In the "Test" solution (but this seems to work without them, too, so why add them there?)
  • In the dependencies of the "Hello World.build" solution (but according to the build language description the dependencies are extracted from the files of the things to build, so I shouldn't add them there either).
  • In the dependencies section inside the build file (but no example shows such a thing, so that might not be the way to go).

So if anyone could give me a clue on how these points I would be very grateful:

  • Why would I need to specify a used language in the "dependencies" section again in my Test-solution?
  • Are there any hard and fast rules for dependencies, like "if you want to use a language in a solution put it here and there", "if you want to use a jar, put it here and there", etc.?
  • Why am I getting these errors for the build script and how could I fix them?

I really think I am missing something totally stupidly simple here because it cannot be that complicated. Now that has been a long post, if you've come so far, thank you for reading it even if you cannot help me :)
5 comments
Comment actions Permalink
Hello Jan,

admittedly, this is quite an involved topic.

There are two parts to your question.
First, you should have added a "Dependency" of the sandbox solution on "JDK", not on the "HelloWorldLanguage". Since your sandbox models get translated into Java, the JDK classes must be available for the generator as a dependency.

Second, it seems you have been too aggressive removing dependencies from the build script. You should have a dependency on "mps (artifacts location $mps_home)".

I hope this helps shed some light on the dependencies in MPS.

Vaclav
0
Comment actions Permalink
Hello Vaclav,

thank you for your suggestions, that at least made the project compile. However I still fail to get a proper jar from my Test solution. I tried entering "module Test" in the "default layout" section but that just gave some error about missing sources when running the ant script.

module.jpg


So I tried "jar" containing "compile output of <Module>", however the "Test" solution is not given as a proper option for "compile output of <Module>".

jar.jpg


Is it actually possible building a solution into a jar (e.g. i want a jar of the created HelloWorld class) with BuildLanguage? The Build Language description only mentions IDE plugins and standalone IDEs, but I actually want to create a plain jar library.
0
Comment actions Permalink
Since you require java compilation, you should list the "java" plugin among the "used plugins". This should do the trick. you may then refer to the module as:

jar result.jar
    module Test
0
Comment actions Permalink
Awesome, that works. Can't believe I missed that. Now that you state it it's totally obvious.

Much to learn I still have :)

Thank you very much, Vaclav!
0
Comment actions Permalink
You are welcome, Jan. Clearly there are places where MPS should be more intuitive.

Vaclav
0

Please sign in to leave a comment.