0

I am trying to make a basic program using XTend for Intellij 15.0.5 (Ultimate) but for some reason I cannot run/compile any ".xtend" files.

Writing the following code is no problem and the ide checks for syntax errors as expected:

package presentation

class Greeter {
    def static void main(String[] args){
        println("Hello World!");
    }
}

I downloaded and installed the custom language plugin and I can create a new Java project with XTend. However, I cannot run/compile any xtend files.

When performing a right click on the xtend file there is no "run". More interestingly, Intellij allows me to refactor normal java classes into xtend classes. Also, I cannot choose Greeter as Main class in the Run Configuration.

Of course, I also added the mandatory libraries (core, lib and macro). I really don't know what I am missing but I suppose it must be something very obvious. Apart from running/compiling everything seems to work like a charm.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

1 Answers1

0

I had a similar problem myself as I am just starting out with Xtend.

As far as I can tell you don't run Xtend files as much as you run/compile java files that get auto generated by Xtext (The parser system Xtend uses).

The problem I had (and the one you also most likely have) was caused by the module not having Xtend generation enabled. After many frustration related headaches I fixed this problem by opening the Project Structure page, clicking on the Modules tab, selecting my desired module, clicking the green plus icon and then choosing Xtend from the resulting menu.

It should then show a panel with a bunch of options (you should leave these the way they are for now and then click OK).

IntelliJ will then auto generate a java file for each xtend file. To run the project you just configure your application launcher so that it points to the generated java file containing your main method and then you should be good to go.

Hope this helps.

  • 1
    thank you for the fast answer! However, I don't have a "xtend" menu when I click on the green plus :/ Moreover, none of the classes I write are rewritten into the xtend-src folder. – ImaginaryNumb3r May 04 '16 at 14:59
  • 1
    I already had the module, but target/xtend-gen/main was not marked as a source folder, once I did that, it worked. – Tony BenBrahim Jul 15 '17 at 15:49