version: '{build}'
skip_tags: true
clone_depth: 30

environment:
  matrix:
    - JAVA_HOME: C:\Program Files\Java\jdk1.8.0
    - JAVA_HOME: C:\Program Files\Java\jdk11

install:
  - cmd: SET PATH=%JAVA_HOME%\bin;%PATH%

build_script:
  - mvn clean install -B -DskipTests

test_script:
  - mvn clean install -B

on_failure:
  - ps: |
      7z a -r surefire-reports.zip '**\target\surefire-reports\*'
      Push-AppveyorArtifact surefire-reports.zip -DeploymentName 'Surefire Reports'

on_finish:
  - ps: |
      $url = "https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)"
      $wc = New-Object 'System.Net.WebClient'
      $dirs = Get-ChildItem -Filter surefire-reports -Recurse
      ForEach ($dir in $dirs)
      {
        $files = Get-ChildItem -Path $dir.FullName -Filter TEST-*.xml
        ForEach ($file in $files)
        {
          $wc.UploadFile($url, (Resolve-Path $file.FullName))
        }
      }
