1

Follow-up of Is there a P2 repository with an up-to-date javassist?

The issue I have is related to Java lambdas. I am also using xtend, and xtend lambdas are generated as Java lambdas if source level compatibility is set to Java 8+, but as anonymous classes.

I know how to set the source compatibility level in Eclipse, but how do I configure it for xtend-maven-plugin? I did not find documentation.

kutschkem
  • 7,826
  • 3
  • 21
  • 56
  • Have you set the correct source and target for the maven compiler plugin? – J Fabian Meier Oct 18 '19 at 09:27
  • @JFMeier What you are saying is I should just put source level 1.8 and target level 1.7 in maven compiler plugin? I'll try that. – kutschkem Oct 18 '19 at 09:30
  • Why not both 1.8? I don't think source level can be higher than target level. – J Fabian Meier Oct 18 '19 at 09:33
  • @JFMeier Both ARE 1.8 right now, the issue is that I have an outdated javassist version which has issues with 1.8 lambdas. I am getting my javassist from Orbit and would like to avoid having to handle P2 metadata myself if I can help it, so I am looking for a workaround instead of updating javassist (which includes some work on P2 metadata). – kutschkem Oct 18 '19 at 09:35
  • Ok, then just forget my comments. – J Fabian Meier Oct 18 '19 at 09:37

2 Answers2

2

This is with xtend 2.20.

The 2.14.0 answer did not work for me. I had to use

<configuration>
    <javaSourceVersion>1.8</javaSourceVersion>
</configuration>

in my pom file to force the xtend maven plugin to produce Java 8 code instead of the default, which is Java 1.6.

kutschkem
  • 7,826
  • 3
  • 21
  • 56
Lutz Wrage
  • 46
  • 4
  • Can you say which xtend version this is? I will add the xtend version to my answer, too. This way others will have an easier time to figure out which property needs to be used. – kutschkem Feb 17 '20 at 07:28
1

How to set source level compatibility for xtend-maven-plugin 2.14.0

The property for this is maven.compiler.source.

    <plugin>
        <groupId>org.eclipse.xtend</groupId>
        <artifactId>xtend-maven-plugin</artifactId>
        <version>2.14.0</version>
        <configuration>
            <maven.compiler.source>1.7</maven.compiler.source>
        </configuration>
    </plugin>

How I found this information

Maybe this can help someone in the future: Since this plugin has next to no documentation, I went to the Mojo source code and found:

/**
 * Create Java Source Code that is compatible to this Java version.
 * 
 * Supported values: 1.5, 1.6, 1.7, 1.8, 9 and 10
 */
@Parameter(property="maven.compiler.source", defaultValue="1.6")
private String javaSourceVersion;
kutschkem
  • 7,826
  • 3
  • 21
  • 56