Xtend force java 7

By : fwind
Source: Stackoverflow.com
Question!

I am using Xtend in intellij using 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 language level?

By : fwind


Answers

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



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.

By : A.H.


This video can help you solving your question :)
By: admin