name: Java CI

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        java: [ 11, 17, 21 ]

    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-java@v5
        with:
          distribution: zulu
          java-version: ${{ matrix.java }}
      - uses: actions/cache@v4
        with:
          path: ~/.m2
          key: ${{ runner.os }}-${{ matrix.java }}-m2-${{ hashFiles('**/pom.xml') }}
          restore-keys: ${{ runner.os }}-${{ matrix.java }}-m2
      - run: mvn --batch-mode --update-snapshots -Dgpg.skip=true jacoco:prepare-agent verify jacoco:report
      - uses: codecov/codecov-action@v5
        with:
          file: ./**/target/site/jacoco/jacoco.xml
          token: ${{ secrets.CODECOV_TOKEN }}
          name: codecov
