Standalone command-line compiler

We already know that the Xtext project wizard created the projects for our DSL separating the features related to the user interface in a separate project (the .ui project); the runtime project does not depend on the Eclipse user interface. Thus, we can create a command-line application consisting of a simple Java class with a main method. Simply add the following lines to your MWE2 workflow file:

// generator API
fragment = generator.GeneratorFragment {
  generateJavaMain = true
}

If you now run the workflow, you will find a Main class in the src folder of your project in the org.example.entities.generator package. As you may recall from Chapter 2, Creating Your First Xtext Language, files generated into the src

Get Implementing Domain-Specific Languages with Xtext and Xtend now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.