# Licensed to Julian Hyde under one or more contributor license
# agreements.  See the NOTICE file distributed with this work
# for additional information regarding copyright ownership.
# Julian Hyde licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this
# file except in compliance with the License.  You may obtain a
# copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
# either express or implied.  See the License for the specific
# language governing permissions and limitations under the
# License.
#
name: Java CI

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        java-version: [ "11" ]
        guava-version: [ "" ]
        hsqldb-version: [ "" ]
        checkstyle-version: [ "" ]
        javadoc: [ false ]
        include:
          - java-version: "8"
            guava-version: "19.0"
            hsqldb-version: "2.5.1"
            checkstyle-version: "9.3"
            javadoc: false
          - java-version: "17"
            guava-version: "23.0"
            javadoc: true
          - java-version: "17"
            guava-version: "31.1-jre"
            javadoc: false
            checkstyle-version: ""
          - java-version: "18"
            javadoc: false

    steps:
      - uses: actions/checkout@v1
        with:
          fetch-depth: 0
      - name: Set up JDK
        uses: actions/setup-java@v1
        with:
          java-version: ${{ matrix.java-version }}
          distribution: 'adopt'
      - name: Build with Maven
        run: |
          GOALS=verify
          if [ "${{ matrix.javadoc }}" = true ]
          then
            GOALS="$GOALS javadoc:javadoc javadoc:test-javadoc"
          fi
          DEFS="-Dmorel.ci"
          if [ "${{ matrix.checkstyle-version }}" ]
          then
            DEFS="$DEFS -Dcheckstyle.version=${{ matrix.checkstyle-version }}"
          fi
          if [ "${{ matrix.guava-version }}" ]
          then
            DEFS="$DEFS -Dguava.version=${{ matrix.guava-version }}"
          fi
          if [ "${{ matrix.hsqldb-version }}" ]
          then
            DEFS="$DEFS -Dhsqldb.version=${{ matrix.hsqldb-version }}"
          fi
          mvn $DEFS --batch-mode --update-snapshots $GOALS

# End main.yml
