Installing Java 17 / Amazon Corretto 17 on AWS Codebuild for Apache Maven Builds

UPDATE: AWS CodeBuild supports Amazon Corretto 17 (Java 17)

The AWS CodeBuild image aws/codebuild/standard:5.0 ships only with Amazon Corretto 8 (/usr/lib/jvm/java-1.8.0-amazon-corretto/) and 11 (/usr/lib/jvm/java-11-amazon-corretto/) (Java 8 / 11).

Java 17 / Amazon Corretto 17 can be installed with the following commands in the buildspec.yml:


version: 0.2
env:
  variables:
    JAVA_HOME: "/usr/lib/jvm/java-17-amazon-corretto/"
phases:
    install:
        commands:
            - apt-get update; apt-get install -y java-17-amazon-corretto-jdk
            - update-alternatives --auto javac
            - update-alternatives --auto java
    build:
        commands:
            - cd ${CODEBUILD_SRC_DIR}/(...) && mvn package    

The JAVA_HOME variable declared in the env section forces Apache Maven to use the installed Amazon Corretto 17.

You can list all available build images with the following command: aws codebuild list-curated-environment-images

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
...the last 150 posts
...the last 10 comments
License