Setting Up Xtend with Maven and eclipse (Luna)

Xtend is currently my favourite alternative language for the JVM (closely followed by Kotlin). Unfortunately, I did not find a good guide of how to set up a Maven project within eclipse (Luna) which uses Xtend.

Specifically the following guide will allow you to allow you to write test cases in Xtend for your existing Java projects. A great way to get started with Xtend I suppose.

The following describes the necessary steps.

  • Install the Xtend plugin for eclipse as described here.
  • Add the xtend-maven-plugin to your pom.xml as follows:


  • Also add a dependency to the Xtend runtime libraries
  • Right click the project and select Maven / Update Project … and update the project.
  • Right clock the project and select Properties
  • Go to the Xtend / Compiler page
  • Set as the ouput director src/test/java

  • Go to the folder src/test/xtend. If the folder does not exist, create it.
  • Right clock the folder src/test/xtend and select Build Path / Use As Source Folder
  • Create a package in the new src/test/xtend folder and right click the package. Select New / Xtend class and define a class such as the following:

import org.junit.Assert
import org.junit.Test

class TestThatNumbersAreEqual {
    def void test() {
        Assert.assertTrue(3 == 3)
  • Immediately after you save the class a translated class should be created in the folder src/test/java

Now, have fun writing tests using Xtend’s concise syntax – while not affecting any step of your build and development workflow!

To see an example configuration in a complete project, also check out async-map on GitHub.

3 thoughts on “Setting Up Xtend with Maven and eclipse (Luna)

  1. You don’t need to customize the source folder, it is automatically configured by the maven integration. The field you changed has no effect anyway, since output per source folder is used 😉

    Also there is a Xtend maven archetype, so just use New -> Maven Project and select that archetype and everything is set up correctly.

    I just noticed that this information is not mentioned on the download page. I know I updated it in the repository, but it probably didn’t get pushed.

    1. Thank you for the clarification and especially for your work on the Xtend Maven infrastructure! Xtend really integrates very nicely with Maven! I added a note about the archetype in the post. However, I believe using the archetype (version 2.7.2 I tried) would use different source paths by default than described in the post? I kind of like generating into the default Maven Java source paths, so that the resulting project looks very much like a normal Java project from the outside – but I am happy to be corrected if that’s a bad idea.

      1. You are right, it will generate into the target folder, so that “maven clean” will automatically delete the generated Java code.

        But if you want to check in the generated code, you can of course change the folder. Still starting with the archetype will probably be less typing.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s