--- layout: post title: Xtext 2.5.0 Release Notes date: 2013-12-11 09:30:28 categories: releasenotes ---

Xtext 2.5.0 includes more than 100 bug fixes and enhancements. Some of the more important enhancements are :

Better Maven Support

Xtext 2.5.0 comes with much improved support for integrating Xtext languages and the corresponding code generators in continuous integration builds. All the needed jars are available on Maven central now and we have added a dedicated Maven compiler plug-in that simulates the incremental build in a headless Java Maven build (no Tycho needed!). Please read the new section in the documentation for more details on the new Maven support.

<plugin>
  <groupId>org.eclipse.xtext</groupId>
  <artifactId>xtext-maven-plugin</artifactId>
  <version>2.5.0</version>
  <executions>
    <execution>
      <goals>
        <goal>generate</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <languages>
      <language>
        <setup>my.mavenized.HeroLanguageStandaloneSetup</setup>
        <outputConfigurations>
          <outputConfiguration>
            <outputDirectory>src/main/generated-sources/xtend/</outputDirectory>
          </outputConfiguration>
        </outputConfigurations>
      </language>
    </languages>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>my.mavenized.herolanguage</groupId>
      <artifactId>my.mavenized.herolanguage</artifactId>
      <version>1.0.0-SNAPSHOT</version>
    </dependency>
  </dependencies>
</plugin>	
	

Enhancements for Xbase

The Xbase language and compiler has been improved in many ways.

Full support for Annotations

Xbase now supports all annotation values and constant expressions in annotations.

class MyEntity {
  @Columns(#[@Column('id'), @Column(value = 'timestamp', length = 2 * 3 * 7)])
  CompositeKey key
}
	

Method overload validation

Ambiguous method invocations are checked and reported with a detailled message. The compiler optionally detects valid but suspiciously overloaded methods that could be implemented by accident. This is especially handy when property access and extension methods come into play.

Here's an example how it is used within Xtend.

class A {
  def isCheck() {..}
}
class B extends A {
  def m() {
    /*
     * Ambiguous feature call.
     * The methods
     * 	getCheck() in B and
     * 	isCheck() in A
     * both match.
     */ 
    this.check
  }
  def getCheck() {..}
}
	
Important note:

You have to make sure to use the library in version 2.5 along with the introduced compiler checks.

Discouraged variable names

Some variable names are used implicitely by Xtend, for example the variable name 'self'. The compiler optionally reports if these names were picked manually.

Auto casts

Xbase supported auto-casts right from the beginning with its powerful switch expression. In 2.5, the more familiar syntax with instance-of checks caught up and also applies automatic casts in if expressions and while loops.

if (c instanceof String) {
  c.substring(42)
}
	

Switch over enums

One of the few places where Xbase's syntax could be improved compared to Java, was a switch expression over enumeration values. Now it's no longer necessary to use a qualified name or static imports for the enum values but the literals are available automatically for the case guards.

switch p {
  case CLASS: 1
  case RUNTIME: 2
  case SOURCE: 3
}
	

Improved type inference with primitive values

The local type inference has been improved when primitive types are involved. Their wrapper types will be used in fewer cases which prevents unexpected exceptions at runtime. An optional compiler check can point to places where primitive defaults are used rather than explicit values.