Compiling Xtend code to Java 8 with Maven

327 views
Skip to first unread message

Norbert Sándor

unread,
Dec 4, 2015, 4:04:46 AM12/4/15
to Xtend Programming Language
Hello,

I have read some posts about this topic but I cannot get compilation to work with Java 8 source level...

I think I have everything in place:
  • maven-compiler-plugin: source and target is set to 1.8
  • maven-toolchains-plugin: jdk/version is set to 1.8
During compilation the toolchain is applied:

[INFO] --- xtend-maven-plugin:2.9.0:compile (default)
[INFO] Using toolchain JDK[...\jdk1.8.0]


But when I try to compile an interface with a default method, I get the following error:

ERROR:  IocApi.xtend - ...\IocApi.xtend
266: Abstract methods do not specify a body

In Eclipse, the same code compiles without problems.

Any ideas?

Thanks,
Norbi

Norbert Sándor

unread,
Dec 9, 2015, 1:26:00 PM12/9/15
to Xtend Programming Language
If you have some time to try it:
Error message:

[INFO] --- xtend-maven-plugin:2.9.0:compile (default) @ xtend-ioc-core ---

[INFO] Using toolchain JDK[...\jdk1.8.0]
[ERROR]
ERROR:  IocApi.xtend - ...\xtend-ioc-project\xtend-ioc-core\src\main\java\com\erinors\ioc\shared\api\IocApi.xtend
268: Abstract methods do not specify a body


In Eclipse it compiles as expected.

Thanks for your help in advance.
Norbi

Norbert Sándor

unread,
Dec 9, 2015, 1:32:20 PM12/9/15
to Xtend Programming Language
Sorry, you should use

mvn compile -P!release

because some Maven components are configured only on my machine :)

Norbert Sándor

unread,
Dec 9, 2015, 1:44:55 PM12/9/15
to Xtend Programming Language
I see something related in the detailed Maven log:

[DEBUG] Configuring mojo 'org.eclipse.xtend:xtend-maven-plugin:2.9.0:compile' wi
th basic configurator -->
...
[DEBUG]   (f) javaSourceVersion = 1.6
...
[DEBUG] Set Java Compliance Level: 1.6
...

But where do these settings come from?

Norbert Sándor

unread,
Dec 9, 2015, 1:49:07 PM12/9/15
to Xtend Programming Language
I solved it by explicitly specifying

<javaSourceVersion>1.8</javaSourceVersion>

in the xtend-maven-plugin configuration.

Stefan Oehme

unread,
Dec 10, 2015, 1:47:55 AM12/10/15
to Xtend Programming Language
Hi Norbert,

Xtend cannot see the configuration of the java plugin. But maven has two useful properties you can set instead. These are understood by both java and xtend.

<properties><maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>

Cheers,
Stefan

Norbert Sándor

unread,
Dec 10, 2015, 3:19:25 AM12/10/15
to Xtend Programming Language
Thanks!

(I think it works only if all xtend projects are built with the same Java source level.)


--
You received this message because you are subscribed to a topic in the Google Groups "Xtend Programming Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/xtend-lang/88WLQx6b10k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to xtend-lang+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stefan Oehme

unread,
Dec 10, 2015, 3:54:28 AM12/10/15
to xtend...@googlegroups.com
You can set that property differently on different projects if you want.
Reply all
Reply to author
Forward
0 new messages