# build does not work on Java 9 or later as Java 5 is not a valid target

name: Build

on:
  push:
    branches:
      - '*'
  pull_request:
    branches:
      - 'main'
  workflow_dispatch:

permissions:
  contents: read

jobs:
  build:
    permissions:
      security-events: write  # for github/codeql-action
    runs-on: ubuntu-latest

    steps:
    - name: Checkout
      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683  #v4.2.2

    - name: Set up JDK
      uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12  #v4.7.0
      with:
        java-version: 8
        distribution: 'temurin'
        cache: 'maven'

    - name: Maven version
      run: |
        mkdir -p ./.mvn
        echo "-e" >> ./.mvn/maven.config
        echo "-B" >> ./.mvn/maven.config
        echo "-ntp" >> ./.mvn/maven.config
        echo "-DtrimStackTrace=false" >> ./.mvn/maven.config
        echo "--settings" >> ./.mvn/maven.config
        echo "$( pwd )/.github/maven-settings.xml" >> ./.mvn/maven.config
        mvn --version
        mkdir -p target

    #------------------------------------------------------------------------
    - name: Initialize CodeQL
      uses: github/codeql-action/init@70df9def86d22bf0ea4e7f8b956e7b92e7c1ea22  #codeql-bundle-v2.20.7
      with:
        languages: java

    - name: Maven build
      run: |
        mvn install site

    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@70df9def86d22bf0ea4e7f8b956e7b92e7c1ea22  #codeql-bundle-v2.20.7
