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 separate projects, the .ide
project and 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 class with a main
method. Xtext can generate such a class for you. We need to add the generator
specification in the StandardLanguage
block in the MWE2 workflow file:
language = StandardLanguage {
name = "org.example.entities.Entities"
fileExtensions = "entities"
...
generator = {
generateXtendMain = true
}
}
If you now run the workflow, you will find an Xtend 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
folder are only generated once, and thus you can safely add...