我尝试用maven创建一个非常简单的JavaFX项目,并使用GitHub操作从它构建一个Linux包。这是工作流文件:
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Linux Client
on:
workflow_dispatch:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
- name: Debug
run: mvn -version
- name: Build with Maven
run: sudo mvn -e -B install --file pom.xml
- name: Upload DEB package
uses: actions/upload-artifact@v2
with:
name: Installer files
path: target/installer/*
从https://github.com/dlemmermann/JPackageScriptFX开始。
工作流文件设置了JDK 17,mvn -version
似乎有正确的输出:
Run mvn -version
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /usr/share/apache-maven-3.8.6
Java version: 17.0.4.1, vendor: Eclipse Adoptium, runtime: /usr/lib/jvm/temurin-17-jdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.15.0-1017-azure", arch: "amd64", family: "unix"
编译失败,出现Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project TestMaven: Fatal error compiling: error: release version 17 not supported -> [Help 1]
。
我做错了什么?
2条答案
按热度按时间xjreopfe1#
我自己找到了答案,原来我无意中用sudo运行了maven(在此之前我遇到了一些其他错误,并认为这是一个无害的修复)。
setup-java操作似乎只为标准用户更新JAVA_HOME,因此maven尝试使用预先安装在运行器上的版本11。
0qx6xfy62#
将Windows上的JAVA_HOME设置为Java 17安装路径。重新启动IDE或命令行。