| # Licensed to the Apache Software Foundation (ASF) under one or more | |
| # contributor license agreements. See the NOTICE file distributed with | |
| # this work for additional information regarding copyright ownership. | |
| # The ASF 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 Maven | |
| on: | |
| # Deliberately NOT filtered by path. "Build and Test (JDK 17)" is a required | |
| # status check in .asf.yaml, and a workflow skipped by path filtering never | |
| # reports its checks - they stay Pending and the pull request can never be | |
| # merged. The build job always runs instead, and its steps are skipped by | |
| # condition when the detect-changes action says nothing needs building. | |
| pull_request: | |
| push: | |
| branches: | |
| - 'main' | |
| - 'develop' | |
| - 'release/*' | |
| - 'support/*' | |
| workflow_dispatch: | |
| workflow_call: | |
| permissions: read-all | |
| # Pull requests cancel superseded runs; pushes get unique groups so none is dropped. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }} | |
| cancel-in-progress: true | |
| env: | |
| MAVEN_OPTS: -Xmx2048m -Xms1024m | |
| LANG: en_US.utf8 | |
| jobs: | |
| build: | |
| name: Build and Test (JDK ${{ matrix.java }})${{ matrix.profile == '-Pjakartaee11' && ' (Jakarta EE 11 + Spring 7)' || matrix.profile }} | |
| # No job-level `if:` here on purpose. A matrix job whose condition is false | |
| # is skipped *before* the matrix expands, so it reports a single check run | |
| # named after the raw `${{ matrix.* }}` template - never "Build and Test | |
| # (JDK 17)". The required context then never reports at all and the pull | |
| # request stays blocked. Gate the steps instead: the matrix expands, every | |
| # expected check reports success, and nothing is built. | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| java: [ '17', '21', '25' ] | |
| profile: [ '', '-Pjakartaee11' ] | |
| exclude: | |
| - java: '17' | |
| profile: '-Pjakartaee11' | |
| # Pull requests build the oldest JDK and the newest on Jakarta EE 11; pushes build everything. | |
| - java: ${{ github.event_name == 'pull_request' && '21' || 'none' }} | |
| - java: ${{ github.event_name == 'pull_request' && '25' || 'none' }} | |
| profile: '' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| - name: Detect changes | |
| id: changes | |
| uses: ./.github/actions/detect-changes | |
| - name: Setup Java ${{ matrix.java }} | |
| if: steps.changes.outputs.code == 'true' | |
| uses: actions/setup-java@v6 | |
| with: | |
| distribution: temurin | |
| java-version: ${{ matrix.java }} | |
| cache: 'maven' | |
| - name: Maven Verify on Java ${{ matrix.java }}${{ matrix.profile == '-Pjakartaee11' && ' (Jakarta EE 11 + Spring 7)' || matrix.profile }} | |
| if: steps.changes.outputs.code == 'true' | |
| run: mvn -B -V -DskipAssembly verify ${{ matrix.profile }} --no-transfer-progress | |
| - name: Test Summary ${{ matrix.java }} ${{ matrix.profile }} | |
| uses: mikepenz/action-junit-report@8a133bfa3ecb0ea9024c1e2ae788b4c25f6cdb9d #v6.6.2 | |
| continue-on-error: true | |
| if: always() && steps.changes.outputs.code == 'true' | |
| with: | |
| annotate_only: true # forked repo cannot write to checks so just do annotations | |
| report_paths: | | |
| **/surefire-reports/TEST-*.xml | |
| **/failsafe-reports/TEST-*.xml | |