name: Samples Java Server

on:
  push:
    paths:
      # java-camel is tested locally for the time being
      #- 'samples/server/petstore/java-camel/**'
      - 'samples/server/petstore/java-vertx-web/**'
      - 'samples/server/petstore/java-inflector/**'
      - 'samples/server/petstore/java-pkmst/**'
      - 'samples/server/petstore/java-undertow/**'
  pull_request:
    paths:
      #- 'samples/server/petstore/java-camel/**'
      - 'samples/server/petstore/java-vertx-web/**'
      - 'samples/server/petstore/java-inflector/**'
      - 'samples/server/petstore/java-pkmst/**'
      - 'samples/server/petstore/java-undertow/**'
jobs:
  build:
    name: Build Java Server
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        sample:
          # servers
          #- samples/server/petstore/java-camel/
          - samples/server/petstore/java-vertx-web/
          - samples/server/petstore/java-inflector/
          - samples/server/petstore/java-pkmst/
          - samples/server/petstore/java-undertow/
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-java@v3
        with:
          distribution: 'temurin'
          java-version: 8
      - name: Cache maven dependencies
        uses: actions/cache@v3
        env:
          cache-name: maven-repository
        with:
          path: |
            ~/.m2
          key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
      - name: Build
        working-directory: ${{ matrix.sample }}
        run: mvn clean package
