Search code examples
javamaveneclipse-plugineclipse-rcptycho

Maven Tycho compilation failure


I am using maven and tycho plug-in to build an eclipse RCP application. I use some java 8 features like lambda expression, but it could not build correctly because of compilation failure.

[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:1.0.0:compile (default-compile) on project ***.***: Compilation failure: Compilation failure:      
[ERROR]     .filter(Objects::nonNull)
[ERROR]             ^^^^^^^^^^^^^^^^
[ERROR] Method references are allowed only at source level 1.8 or above
[ERROR] 2 problems (2 errors)
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

My questions are:

  • Do you think the files .settings/org.eclipse.jdt.core.prefs and .classpath (I guess not for this one) are necessary for the build of maven tycho? Do I have to explicitly define java 8 in those files?
  • Do I have to specify something else in the pom files?

Solution

  • As mentioned in the tycho-compiler-plugin documentation, the information in file .settings/org.eclipse.jdt.core.prefs will be passed to the compiler.

    It is necessary then to update the file as follow:

    org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
    org.eclipse.jdt.core.compiler.compliance=1.8
    org.eclipse.jdt.core.compiler.source=1.8