AWS CodeBuild Buildspec.yml example for Gradle and a Micronaut Application

I use Gradle as my build tool of choice for my Micronaut applications.

I often use AWS CodeBuild as my continuous integration service.

I use such a buildspec.yml file:

A buildspec is a collection of build commands and related settings, in YAML format, that CodeBuild uses to run a build.

version: 0.2

phases:
  install:
    runtime-versions:
      java: corretto11 
  build:
    commands:
      - ./gradlew build --scan
  post_build:
    finally:
      - rm -f  /root/.gradle/caches/modules-2/modules-2.lock
      - rm -fr /root/.gradle/caches/*/plugin-resolution/
artifacts:
  files:
    - '*-all.jar'
  base-directory: 'build/libs'
cache:
  paths:
    - '/root/.gradle/caches/**/*' 
    - '/root/.gradle/wrapper/**/*'

My builds include the Gradle Scan plugin.

Because of that I can include the argument --scan which publishes a build scan. An available build scan makes easy to investigate build failures (access tests reports etc).

My next events:
๐Ÿ—“ May 27 09:00 AWS Dublin - Micronaut and AWS Lambda
๐Ÿ—“ Jul 20 09:00 Workshop Security in the Micronaut Framework
๐Ÿ—“ Sep 20 09:00 JCON Online 2022 - Getting Started with the Micronaut Framework
๐Ÿ—“ Sep 23 09:00 JCON Online 2022 - Micronautยฎ Framework and Microstream Java-native persistence engine

Tags: #micronaut #aws #codebuild
May 2021, 24.