The Xtend IDE integration requires Eclipse 3.5 or higher and a Java SDK 5 or higher. Use one of the udpate sites from above to install the full SDK into your running Eclipse. If you do not yet have an Eclipse on your machine, you can download one of the pre-packaged distributions on the right.
There are various options to compile Xtend sources. The most used way is using the Maven plug-in.
If you already have an Eclipse running you should install the "Xtend SDK"-Feature from one of the update sites listed above. To do so
within Eclipse choose Help -> Install New Software.... In the upcoming dialog you should paste one of the update site URLS into the
field named Work with. Now search for the feature
Now the features are being downloaded and installed. Eclipse will ask you for a restart when downloading and installation is done.
You can create a readily configured project using
mvn archetype:generate -DarchetypeGroupId=org.eclipse.xtend -DarchetypeArtifactId=xtend-archetype
If you already have a project with a pom.xml, you need to add the plugin configuration:
<plugin> <groupId>org.eclipse.xtend</groupId> <artifactId>xtend-maven-plugin</artifactId> <version>2.4.3</version> <executions> <execution> <goals> <goal>compile</goal> <!-- <goal>testCompile</goal> --> </goals> <!-- optionally you can configure a different target folder --> <!-- <configuration> <outputDirectory>xtend-gen</outputDirectory> </configuration> --> </execution> </executions> </plugin>
As you see the outputDirectory can be specified to match the default of the Eclipse plug-in (xtend-gen). Of course you can also change the configuration in Eclipse to match the Maven default (generated-sources). To do so right-click on the project and select Properties or if you prefer a global setting choose Eclipse->Preferences. In the category Xtend/Compiler enter the directory name (see screenshot). It is interpreted as a relative path to the parent of the source folder, which includes the to-be-compiled Xtend file.
<dependency> <groupId>org.eclipse.xtend</groupId> <artifactId>org.eclipse.xtend.lib</artifactId> <version>2.4.3</version> </dependency>
When you've started Eclipse for the first time, you should see an empty workspace. Switch to the 'Java perspective' if you are not already in it. Xtend integrates with Java, so you need to create a Java project to get started. In the menu choose File -> New -> Java Project. In the upcoming dialog choose any project name you want (e.g. my.project). After clicking Finish Eclipse will create a fresh project with an empty source folder named '/src'.
To create your first Xtend class select the source folder and press the right mouse button. You should find the entry Xtend class in the category New >. If you don't see it you might not be in the Java perspective or you need to reset the perspective. To do so right click on the perspective icon on the top right and choose reset.
In the dialog you should give the class a name, for instance HelloWorld, and put it into some package (we chose my.namespace). Click Finish and an empty class will be created for you.
The newly created class will have an error marker, saying that you need to put the library on the classpath. There is a "quickfix" which does that for you. Put the cursor on the marked location and press CTRL+1 (or CMD+1 on a Mac) and select the option "Add Xtend libs to the classpath".
The library is also available from maven (see below) or as an OSGi bundle from the p2 update site above.
Now you are ready to code. Within the class body (between the curly braces) type main and press CTRL+space. An empty main method will be generated for you.
Now type in
println('Hello World'), save and run the application. To do so use the green arrow and choose Run As -> Java Application.