name: Build
on:
  push:
    branches:
      - main
      - 2.2.x
    paths-ignore:
      - README.adoc
      - docs/**
  pull_request:
    branches:
      - main
      - 2.2.x
    paths-ignore:
      - README.adoc
      - docs/**

jobs:
  build:
    name: Build
    strategy:
      fail-fast: false
      max-parallel: 12
      matrix:
        os:
          - ubuntu-latest
          - windows-latest
          - macos-latest
        java:
          - 11
          - 17
          - 21
        # Support 1-year-old version + latest minor
        maven:
          - 3.8.8
          - 3.9.6
    runs-on: ${{ matrix.os }}
    steps:
      - uses: s4u/setup-maven-action@v1.11.0
        with:
          java-distribution: 'temurin'
          java-version: ${{ matrix.java }}
          maven-version: ${{ matrix.maven }}
      - name: Maven version
        run: mvn -version
      - name: Build & Test
        run: mvn -B -Prun-its clean verify
  javadocs:
    name: Javadocs
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
        java:
          - 11
        maven:
          - 3.9.6
    runs-on: ${{ matrix.os }}
    steps:
      - uses: s4u/setup-maven-action@v1.11.0
        with:
          java-distribution: 'temurin'
          java-version: ${{ matrix.java }}
          maven-version: ${{ matrix.maven }}
      - name: Build & Test
        run: mvn -B clean javadoc:jar