Run ClassConcept without void main(string[] args)
Hi Community,
i created a concept "Test" which is derived from baselang.ClassConcept. The generator will create a java class with a main() method, so that the class can be executed.
What is the simplest way to execute it directly within mps with a right click - like in the case of classconcepts containing a main().
Best,
Dan
i created a concept "Test" which is derived from baselang.ClassConcept. The generator will create a java class with a main() method, so that the class can be executed.
What is the simplest way to execute it directly within mps with a right click - like in the case of classconcepts containing a main().
Best,
Dan
Please sign in to leave a comment.
We have a concept IMainClass from a language jetbrains.mps.execution.util designed for that purpose. Execution works automatically for concepts that implement it (but the context menu will appear only after first generation of a node).
IMainClass concept has two behavior methods, which you can override if you wish:
- getUnitName which returnes a fully qualified name of a class to be executed. By default it returnes the name of the class generated from this node.
- isNodeRunnable should return true for nodes that can be executed. By default it always returnes true.
--Julia
The robot_Kaja sample has its Script concept as IMainClass. In my regular MPS installation, running a Script node works as expected.
I then set up a build module and built a standalone robot_Kaja MPS build, and when I add a Script to my solution in that, even after building/rebuilding/making the solution and the model, right-clicking on the Script node does not allow me to run it. When I preview the generated text, it does show a main method in the generated class.
Does anyone know what I might be missing, such that the context menu does not give me the option to run the Script?
I've made some progress. I realized I needed to include more plugins in my project's build script.
I've tried adding the following plugins, none of which seem to give me the ability to run an IMainClass from within a standalone IDE build:
I've included these under the "default layout --> folder plugins" section of the build script, and it runs to completion but the resulting standalone IDE still does not allow me to run IMainClass nodes.
Finally figured it out. Lessons learned are: Make sure to understand which plugins your build needs, and make sure to pay attention to the IDE error output when starting the IDE. Those led me to the last plugin dependency I was missing.
Here's a full working build script designed to generate a standalone IDE and allow running the generated code from within the IDE:
Note in particular the dependencies and the plugins used.