name: Build
on: [ push, pull_request ]
permissions: read-all

jobs:
  build-java-8-plus:
    strategy:
      matrix:
        java-version: [ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18-ea ]
        os: [ubuntu-latest, macos-latest, windows-latest]

    runs-on: ${{ matrix.os }}
    steps:
      - name: Harden Runner
        uses: step-security/harden-runner@14dc64f30986eaa2ad2dddcec073f5aab18e5a24 # v1
        with:
          egress-policy: audit

      - name: Checkout
        uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5 # v2

      - name: Validate Gradle Wrapper
        uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b # v1

      - name: Configure JDK ${{ matrix.java-version }}
        uses: actions/setup-java@f0bb91606209742fe3ea40199be2f3ef195ecabf # v2
        with:
          distribution: 'zulu'
          java-version: ${{ matrix.java-version }}
          cache: gradle

      - name: Build
        run: ./gradlew build --no-daemon

  build-java-6-7:
    strategy:
      matrix:
        java-version: [ 6, 7 ]
        os: [ubuntu-latest, windows-latest]

    runs-on: ${{ matrix.os }}
    steps:
      - name: Harden Runner
        uses: step-security/harden-runner@14dc64f30986eaa2ad2dddcec073f5aab18e5a24 # v1
        with:
          egress-policy: audit

      - name: Checkout
        uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5 # v2

      - name: Validate Gradle Wrapper
        uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b # v1

      - name: Configure JDK ${{ matrix.java-version }}
        uses: actions/setup-java@f0bb91606209742fe3ea40199be2f3ef195ecabf # v2
        with:
          distribution: 'zulu'
          java-version: ${{ matrix.java-version }}
          cache: gradle

      - name: Build
        uses: gradle/gradle-build-action@c6619898ec857b418d6436d3efe8a0becf74eb9e # v2
        with:
          gradle-version: 1.12
          build-root-directory: picocli-legacy-tests/
          arguments: clean build --no-daemon
