image: maven:3-jdk-11

    
stages:
  - build
  - test
  - sonar
  - deploy

variables:
  MAVEN_CLI_OPTS: "--batch-mode"
  MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
  SONAR_TOKEN: "c2615224ec33ace4bedeb0f77a9de737b41c24dd"
  SONAR_HOST_URL: "http://84.237.50.237:9000"
  GIT_DEPTH: 0

cache:
  paths:
    - .m2/repository/

build:
  stage: build
  script:
    - mvn $MAVEN_CLI_OPTS compile
    
test:
  stage : test
  script:
    - mvn $MAVEN_CLI_OPTS clean clover:setup test clover:aggregate clover:clover
  artifacts:
    reports:
      junit:
        - target/site/clover/clover.xml
sonar:
  stage : sonar
  script:
    - mvn verify sonar:sonar -Dsonar.qualitygate.wait=true
  allow_failure: true
  only:
    refs:
      - master

pages:
  stage: deploy
  script:
    - mkdir .public
    - cp -r * .public
    - mv .public public
  artifacts:
    paths:
      - public
  only:
    - master