0

I am using Xtend in intellij from the Xtend-plugin. My project language level is set to Java 8 and Xtend compiles fine to Java 8 (e.g. using lambda expressions).

For specific reasons, I need Xtend to generate Java 7 code, without changing the language level of my remaining project (Java 8).

In the Xtend project settings I can set the language level, however this option is ignored. I believe it is ignored because the remaining project still uses JDK 8 and the Java 8 language level.

Is there an option to force Xtend to use a different (lower) language level than the source?

cb4
  • 6,689
  • 7
  • 45
  • 57
fwind
  • 1,274
  • 4
  • 15
  • 32
  • Java 7 code is perfectly compatible with Java 8 code. What proof do you have that this setting is being ignored? – Makoto Sep 06 '16 at 15:59
  • It generates lambda expressions. The generated code is used on the GWT client side, which does not support the new Java 8 features. – fwind Sep 06 '16 at 16:00

2 Answers2

0

There is at least one bug in the Xtend-Compiler which prevents crosscompiling to a lower version of the JDK than the one in the classpath of the project.

Example:

#[ 42, 43 ].forEach[ println(it) ]

If the project if configured to have Java-8 classes in the classpath, the generated Java-Code will automatically use the Java-8 API (the forEach default method of Iterable, Consumer, ...)

This is idependent of any source/target level settings.

A.H.
  • 63,967
  • 15
  • 92
  • 126
-1

I don't many details on the above question but assuming if the project is Maven based then you can target compilation in the pom.xml

<plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-compiler-plugin</artifactId>
 <version>3.5.1</version>
 <configuration>
  <source>1.7</source>
  <target>1.7</target>
 </configuration>
</plugin>