Home > Mobile >  maven-comiler-plugin: Fatal error compiling: error: release version 17 not supported
maven-comiler-plugin: Fatal error compiling: error: release version 17 not supported

Time:09-08

I tried to create a very simple JavaFX project with maven and use GitHub actions to build a linux package from it. This is the workflow file:

# 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/*

adopted from https://github.com/dlemmermann/JPackageScriptFX.

The workflow file sets up JDK 17 and mvn -version seems to have the correct output:

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"

The build fails with 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].

What am I doing wrong?

CodePudding user response:

I found the answer by myself, turns out that I unintentionally ran maven with sudo (I got some other error before that and thought it was a harmless fix).

The setup-java action seems to only update JAVA_HOME for the standard user though, thus maven tried to use version 11 which is preinstalled on the runner.

  • Related