How to use xtext and xpand togheter

699 Views Asked by At

I have a rather silly question. I am using xtext to define a simple dsl and Xpand to generate code.

Now I want to use xpand to read my dsl models and generate code. How can i do that?

I read lot of tutorials saying that I can simple do that by creating a new xtext project from the wizard. Then, among others, the following project will be created:

org.xtext.example.domainmodel.generator.

And inside, the generator looks like this:

  • src
    • model (place the dsl model)
    • templates (place the template for the code generator)
    • workflow (workflow file)

Then i simple run the workflow and generate the code from the dsl file. That s straightforwards and easy.

My problem is that when I create a new xtext project I dont get the org.xtext.example.domainmodel.generator. project. I only have the following four:

org.xtext.example.domainmodel

org.xtext.example.domainmodel.sdk

org.xtext.example.domainmodel.tests

org.xtext.example.domainmodel.ui

So how can i produce the org.xtext.example.domainmodel.generator file???

2

There are 2 best solutions below

0
On

Probably not relevant to the original person who asked this :) but I had a similar problem and the reason was that in my grammar extended xbase.

When extending xbase building the mwe2 skips the generator stub generation and uses the xbase code generation which is generated instead (the antlr parser, serializer etc.)

3
On

Which tutorials do you mean? (links please) And do they really talk about a generator project? Talking about the package org.xtext.example.domainmodel.generator inside the org.xtext.example.domainmodel project is the usual thing.