簡體   English   中英

Maven 第谷編譯失敗

[英]Maven Tycho compilation failure

我正在使用 maven 和 tycho 插件構建一個 eclipse RCP 應用程序。 我使用了一些 java 8 特征,如 lambda 表達式,但由於編譯失敗而無法正確構建。

[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

我的問題是:

  • 你認為文件.settings/org.eclipse.jdt.core.prefs.classpath (我猜不是這個)對於構建 maven tycho 是必要的嗎? 我必須在這些文件中明確定義 java 8 嗎?
  • 我是否必須在pom文件中指定其他內容?

tycho-compiler-plugin文檔中所述,文件.settings / org.eclipse.jdt.core.prefs中的信息將傳遞給編譯器。

然后有必要更新文件如下:

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

您必須在pom.xml文件中指定源級別:

<project>
  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>
</project>

這與tycho無關,它是編譯器插件。

您也可以配置插件本身。

請參閱此頁面

我遇到了同樣的問題,解決方案是將 JAVA_HOME 設置為正確的 JDK。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM