image: maven:3-jdk-7

variables:
  MAVEN_OPTS: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN
               -Dorg.slf4j.simpleLogger.showDateTime=true
               -Djava.awt.headless=true
               -Dmaven.repo.local=.m2/repository"

# Cache downloaded dependencies and plugins between builds.
cache:
  paths:
    - .m2/repository

stages:
  - build
  - publish

before_script:
- export REVISION="$(curl -L https://gitlab.com/ikus-soft/maven-scm-version/-/raw/master/version.sh | bash -)"
- echo "REVISION=$REVISION"

test:
  stage: build
  script:
  - mvn -B -Drevision=${REVISION} clean install

sonar:
  image: maven:3-jdk-8
  stage: build
  allow_failure: true
  script:
  - mvn -B -Drevision=${REVISION} -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_TOKEN org.jacoco:jacoco-maven-plugin:prepare-agent clean verify sonar:sonar

nexus_deploy:
  stage: publish
  script:
  - mvn -B -s ./settings.xml -Drevision=${REVISION} clean install deploy
