variables:
  MAVEN_CACHE_FOLDER: $(Pipeline.Workspace)/.m2/repository

trigger: none

pr:
- master
- release

# Different users have different machine setups, we run the build three times, on ubuntu, osx, and windows.
# Azure doesn't always have the same Java versions on each system, so they are enumerated for each system independently.
jobs:
  - job: setup
    displayName: cache-maven-dependencies
    pool:
      vmImage: ubuntu-latest
    steps:
      - checkout: self
        fetchDepth: 1
      - task: Cache@2
        inputs:
          key: maven | $(Build.BuildId)
          path: $(MAVEN_CACHE_FOLDER)
      - task: Bash@3
        inputs:
          targetType: 'inline'
          script: mkdir -p $(MAVEN_CACHE_FOLDER); pwd; ls -al $(MAVEN_CACHE_FOLDER)
      - task: Maven@3
        inputs:
          mavenPomFile: 'pom.xml'
          options: '-Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)'
          mavenOptions: '-Xmx3072m'
          javaHomeOption: 'JDKVersion'
          jdkVersionOption: '1.11'
          jdkArchitectureOption: 'x64'
          publishJUnitResults: false
          goals: 'dependency:resolve'
      - task: Maven@3
        inputs:
          mavenPomFile: 'pom.xml'
          options: '-Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)'
          mavenOptions: '-Xmx3072m'
          javaHomeOption: 'JDKVersion'
          jdkVersionOption: '1.11'
          jdkArchitectureOption: 'x64'
          publishJUnitResults: false
          goals: 'dependency:resolve-plugins'
  - template: pull-request-pipeline-parameterized.yml
    parameters:
      images:
        # This image is here so that at least one job specifically sets Cp1252 file encodings, which are normally set by the JDK (which Azure can change on each latest image)
        - displayName: ubuntu-latest-java-17-cp1252
          vmImage: ubuntu-latest
          jdkVersion: 1.17
          javaToolOptions: -Dfile.encoding=Cp1252
        - displayName: ubuntu-latest-java-11
          vmImage: ubuntu-latest
          jdkVersion: 1.11
          javaToolOptions:
        - displayName: ubuntu-latest-java-17
          vmImage: ubuntu-latest
          jdkVersion: 1.17
          javaToolOptions:
        - displayName: macos-latest-java-11
          vmImage: macos-latest
          jdkVersion: 1.11
          javaToolOptions:
        - displayName: macos-latest-java-17
          vmImage: macos-latest
          jdkVersion: 1.17
          javaToolOptions:
        - displayName: windows-latest-java-11
          vmImage: windows-latest
          jdkVersion: 1.11
          javaToolOptions:
        - displayName: windows-latest-java-17
          vmImage: windows-latest
          jdkVersion: 1.17
          javaToolOptions: