# Installation

Xtend requires Eclipse 3.5 or higher and a Java SDK 5 or higher. The easiest way to install the SDK is via Eclipse Marketplace. But there is also a complete Eclipse distribution available for download at http://xtend-lang.org.

If you do not want to use the recommended Eclipse plug-in, you can compile Xtend code using the Maven plug-in.

## Maven Support

The runtime library as well as a plug-in to run the compiler in a Maven build can be be obtained from the following Maven repository: http://build.eclipse.org/common/xtend/maven/.

Here is the XML for the repository:

<repositories>
<repository>
<id>xtend</id>
<url>http://build.eclipse.org/common/xtend/maven/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>xtend</id>
<url>http://build.eclipse.org/common/xtend/maven/</url>
</pluginRepository>
</pluginRepositories>

Here is the XML for the dependency to the library:

<dependency>
<groupId>org.eclipse.xtend</groupId>
<artifactId>org.eclipse.xtend.lib</artifactId>
<version>2.3.0</version>
</dependency>

And this is the XML for the plug-in:

<plugin>
<groupId>org.eclipse.xtend</groupId>
<artifactId>xtend-maven-plugin</artifactId>
<version>2.3.0</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.

Configuring the compiler in Eclipse

## The Runtime Library

The compiler requires a small runtime library org.eclipse.xtend.lib on the classpath, which provides useful extensions to existing classes and interfaces from the JDK. Many features of Xtend are not built into the language itself but provided via this library. It is available from a Maven repository and via p2 update site (in case you do Eclipse plug-in development). The library provides means to create collections in a readable way:

val myList = newArrayList(1, 2, 3)
val mySet = newHashSet(4, 5, 6)
val myMap = newHashMap(1 -> 'one', 2 -> 'two', 3 -> 'three')

It also extends the collection types with a lot of very useful functions. One example is the ubiquitous map function:

val listOfNames = listOfPersons.map[ name ]

Many operators to concat collections or to do arithmetics with types like BigDecimal are also available.

You might want to have a look at the JavaDoc API to see what is available.