CircleCI 中的 Maven 全新安装

问题描述 投票:0回答:1

我正在尝试 CircleCI 为我的 Maven 项目设置构建管道。 目的是运行

mvn clean install -s settings.xml

我的 config.yml 如下所示

version: 2.1
orbs:
  maven: circleci/[email protected]
  slack: circleci/[email protected]
  docker: circleci/[email protected]

workflows:
  maven:
    jobs:
      - maven/test:
          maven_command: mvn
          command: clean install
          settings_file: settings.xml
          verify_dependencies: false

但由于目标版本 17 错误而失败

[INFO] Changes detected - recompiling the module!
[INFO] Compiling 334 source files to /home/circleci/project/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  04:30 min
[INFO] Finished at: 2023-07-19T00:11:16Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project *****: Fatal error compiling: error: 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.

我应该更改什么配置才能使用 java17?

java maven continuous-integration cicd circleci
1个回答
0
投票

看起来该项目需要 JDK 17,但执行器中不可用。

根据 CircleCI 的 maven orb 中的文档,您可以传入一个可以指定 JDK 版本的执行器,您应该指定 JDK 17。

version: 2.1 orbs: maven: circleci/[email protected] slack: circleci/[email protected] docker: circleci/[email protected] workflows: maven: jobs: - maven/test: executor: name: maven/default tag: '17.0' maven_command: mvn command: clean install settings_file: settings.xml verify_dependencies: false
其中 maven/default 执行器是 cimg/openjdj 便捷 Docker 映像,具有以下可用标签:

https://circleci.com/developer/images/image/cimg/openjdk

希望这有帮助!

© www.soinside.com 2019 - 2024. All rights reserved.