由于目标版本 17 无效,Maven 编译、CircleCI 构建失败

bru*_*550 1 java maven circleci

Maven 本地构建一切正常,但 CircleCI 管道不断失败。这是我的 pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>at.jku</groupId>
    <artifactId>SmartRoom</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.3.3</version>
        </dependency>
    </dependencies>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>

</project>
Run Code Online (Sandbox Code Playgroud)

还有我的 config.yml:

version: 2.1

orbs:
  maven: circleci/maven@0.0.12

workflows:
  maven_test:
    jobs:
      - maven/test:
          command: '-X compile'
Run Code Online (Sandbox Code Playgroud)

我在 CircleCI 中收到的错误消息:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project SmartRoom: Fatal error compiling: invalid target release: 17 -> [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/MojoExecutionException
Run Code Online (Sandbox Code Playgroud)

我已经看过建议的文章,但它并没有真正告诉我任何信息。我已经尝试切换目标版本并从 pom.xml 中完全删除属性。

bru*_*550 6

正如评论中指出的,我的 config.yml 有一些问题。首先,我使用的是旧版本(0.0.12 而不是 1.3.0),此外我必须将 docker Java 17 映像定义为外部执行器才能使一切正常运行。我当前和工作的 config.yml:

version: 2.1
executors:
  java17:
    docker:
      - image: 'cimg/openjdk:17.0'
orbs:
  maven: circleci/maven@1.3.0
workflows:
  maven_test:
    jobs:
      - maven/test:
          command: '-X compile'
          executor: java17
Run Code Online (Sandbox Code Playgroud)