1

I combine Xtext and Xtend. In project, where I write code for my DSL, Xtext work but XTend not generate file in src-gen (this is sources root on: <project-root>/src-gen/). I have this code in function doGenerate

override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) {
        fsa.generateFile("a.txt",'a')
    }

Src-gen is always empty. In eclipse this work. How can I generate file in IntelliJ IDEA or how can I fix this problem. I run in gradle.

Nejc Galof
  • 2,538
  • 3
  • 31
  • 70
  • Did you try the following? Open the Gradle view (**View** | **Tool Windows** | **Gradle**), go to **Tasks** | **build** | **build** and run it by double clicking. – Gabor Szarnyas Nov 18 '16 at 20:34
  • @GáborSzárnyas I try this too. How can I run new application from this build? – Nejc Galof Nov 18 '16 at 21:15
  • The **build** task should regenerate the sources. Some ideas: 1. If you have a class with a `main` method, simply go to the class and click **Run 'ClassName.main()'**. You may also create and run some JUnit tests. 2. Can you try to run the build from the command line? (e.g. `./gradlew build` or `gradle build`) and see what happens? – Gabor Szarnyas Nov 18 '16 at 23:32
  • @GáborSzárnyas Still the same – Nejc Galof Nov 20 '16 at 10:20
  • Is your project originally an Eclipse plug-in? There are quite a few differences between the conventions of Eclipse and Gradle projects: in Eclipse, your main Java source files should be in the `src` dir, while in Gradle, your packages should be in `src/main/java`. Also, generated Xtext files may go to `src-gen` and `src/main/xtext-gen`, respectively. To manage these differences, you can specify custom layouts - see this [example](https://github.com/TypeFox/xtext-vscode/blob/master/gradle/source-layout.gradle) from TypeFox, the company behind Xtext. – Gabor Szarnyas Nov 20 '16 at 21:51
  • @GáborSzárnyas This I use in Xtend project. This is ok. But in new project with `somefile.mydsl` not work any of this path. – Nejc Galof Nov 21 '16 at 19:13

1 Answers1

1

I run gradle task runIdea. I create Java project without any SDK. When project is created, I add "file.mydsl" in src folder. Then I need change facet settings. I open project structure dialog (Ctrl+Shift+Alt+S), in the left-hand panel, click Facets, choose + icon and add DSL facet. Then apply and code is work. In src-gen create a file "a.txt".

Nejc Galof
  • 2,538
  • 3
  • 31
  • 70