name: Java CI with Maven

on:
  push:
  pull_request:

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      matrix:
        java: [ 8, 11, 17, 19 ]
    name: Java ${{ matrix.java }}

    steps:
    - uses: actions/checkout@v4
    - name: Set up Java
      uses: actions/setup-java@v4
      with:
        distribution: 'temurin'
        java-version: ${{ matrix.java }}
    - name: Build with Maven
      run: mvn clean install -Dgpg.skip -Dmaven.javadoc.skip=true

  coverage:
    runs-on: ubuntu-latest
    needs: build
    steps:
    - uses: actions/checkout@v4
    - name: Set up Java
      uses: actions/setup-java@v4
      with:
        distribution: temurin
        java-version: 8
    - name: Build with Maven
      run: mvn clean install -Dgpg.skip -Dmaven.javadoc.skip=true -Dmaven.test.failure.ignore=true
    - name: Upload coverage reports to Codecov
      uses: codecov/codecov-action@v4
      with:
        token: ${{ secrets.CODECOV_TOKEN }}
