box: maven:3.5.2-jdk-8

build:
  steps:
  - script:
      name: setup maven local repo
      code: |
        export MAVEN_OPTS="-Dmaven.repo.local=${WERCKER_CACHE_DIR}"
        mvn -version
        echo "------"
        if [[ $(grep "pull" .git/FETCH_HEAD | cat | wc -l) > 0 ]]; then
          export PR=$(cat .git/FETCH_HEAD | cut -d ' ' -f 1 | cut -d '/' -f 3)
          echo "PR:"$PR
        fi
        echo "------"
        echo "Link ${WERCKER_CACHE_DIR} to /root/.m2/repository for Gradle builds"
        mkdir -p /root/.m2
        ln -s ${WERCKER_CACHE_DIR} /root/.m2/repository
        echo "------"
        du -hs ${WERCKER_CACHE_DIR}
        echo "------"
        du -hs ${WERCKER_CACHE_DIR}/* | sort -h

  - script:
      name: install jq
      code: |
        curl -L http://stedolan.github.io/jq/download/linux64/jq -o /usr/local/bin/jq
        chmod +x /usr/local/bin/jq

  - script:
      name: install groovy
      code: |
         if [ ! -d ${WERCKER_CACHE_DIR}/groovy ]; then
           GROOVY_LINK="https://dl.bintray.com/groovy/maven/apache-groovy-binary-2.4.7.zip"
           wget -O ${WERCKER_CACHE_DIR}/groovy.zip $GROOVY_LINK;
           unzip ${WERCKER_CACHE_DIR}/groovy.zip -d ${WERCKER_CACHE_DIR};
           mv ${WERCKER_CACHE_DIR}/groovy-2.4.7 ${WERCKER_CACHE_DIR}/groovy
         fi
         export GROOVY_HOME=${WERCKER_CACHE_DIR}/groovy
         PATH=$GROOVY_HOME/bin:$PATH
         groovy -v

  - script:
      name: Build Checkstyle
      code: |
        SKIP_FILES1="appveyor.yml|codeship-*|buddy.yml|circleci|travis"
        SKIP_FILES2="|shippable|sonar-|fast-forward-merge.sh|LICENSE|LICENSE.apache20"
        SKIP_FILES3="|README.md|release.sh|RIGHTS.antlr|intellij-idea-inspections.xml"
        SKIP_FILES4="|org.eclipse.jdt.core.prefs|jsoref-spellchecker"
        SKIP_FILES5="|check-only-javadoc-error.sh|eclipse-compiler-javac.sh|idea_inspection"
        SKIP_FILES6="|test-spelling-unknown-words.sh|Jenkinsfile"
        SKIP_FILES=$SKIP_FILES1$SKIP_FILES2$SKIP_FILES3$SKIP_FILES4$SKIP_FILES5$SKIP_FILES6
        export RUN_JOB=1
        source ./.ci/common.sh
        # should_run_job will change RUN_JOB variable
        should_run_job "recheck" $SKIP_FILES
        if [[ $RUN_JOB == 1 ]]; then
          mvn -e clean install -Pno-validations
        else
          echo "build is skipped ..."
        fi

  - script:
      name: NoErrorTest - Postgresql JDBC Driver
      code: |
        if [[ $RUN_JOB == 1 ]]; then
          echo "Command: ./.ci/wercker.sh no-error-pgjdbc"
          ./.ci/wercker.sh no-error-pgjdbc
        else
          echo "build is skipped ..."
        fi

  - script:
      name: NoErrorTest - Orekit
      code: |
        if [[ $RUN_JOB == 1 ]]; then
          echo "Command: ./.ci/wercker.sh no-error-orekit"
          ./.ci/wercker.sh no-error-orekit
        else
          echo "build is skipped ..."
        fi

  - script:
      name: NoErrorTest - XWiki
      code: |
        if [[ $RUN_JOB == 1 ]]; then
          echo "Command: ./.ci/wercker.sh no-error-xwiki"
          ./.ci/wercker.sh no-error-xwiki
        else
          echo "build is skipped ..."
        fi

  - script:
      name: NoErrorTest - Apache Apex
      code: |
        if [[ $RUN_JOB == 1 ]]; then
          echo "Command: ./.ci/wercker.sh no-error-apex-core"
          ./.ci/wercker.sh no-error-apex-core
        else
          echo "build is skipped ..."
        fi

# disabled till project migrate to config of 8.28
#  - script:
#      name: NoErrorTest - Strata
#      code: |
#        if [[ $RUN_JOB == 1 ]]; then
#          echo "Command: ./.ci/wercker.sh no-error-strata"
#          ./.ci/wercker.sh no-error-strata
#        else
#          echo "build is skipped ..."
#        fi

  - script:
      name: NoErrorTest - Hibernate Search
      code: |
        if [[ $RUN_JOB == 1 ]]; then
          echo "Command: ./.ci/wercker.sh no-error-hibernate-search"
          ./.ci/wercker.sh no-error-hibernate-search
        else
          echo "build is skipped ..."
        fi

  - script:
      name: NoErrorTest - EqualsVerifier
      code: |
        if [[ $RUN_JOB == 1 ]]; then
          echo "Command: ./.ci/wercker.sh no-error-equalsverifier"
          ./.ci/wercker.sh no-error-equalsverifier
        else
          echo "build is skipped ..."
        fi

  - script:
      name: NoErrorTest - Spring Integration
      code: |
        if [[ $RUN_JOB == 1 ]]; then
          echo "Command: ./.ci/wercker.sh no-error-spring-integration"
          ./.ci/wercker.sh no-error-spring-integration
        else
          echo "build is skipped ..."
        fi

  # Disabled as it result in "svn: E175002: Unexpected HTTP status 429 'Too Many Requests'"
  # even for "svn checkout -r 14923 ...."
  # - script:
  #     name: NoErrorTest - HtmlUnit
  #     code: |
  #       if [[ $RUN_JOB == 1 ]]; then
  #         echo "Command: ./.ci/wercker.sh no-error-htmlunit"
  #         ./.ci/wercker.sh no-error-htmlunit
  #       else
  #         echo "build is skipped ..."
  #       fi

  - script:
     name: NoErrorTest - checkstyle's sevntu
     code: |
       if [[ $RUN_JOB == 1 ]]; then
         echo "Command: ./.ci/wercker.sh no-error-checkstyles-sevntu"
         ./.ci/wercker.sh no-error-checkstyles-sevntu
       else
         echo "build is skipped ..."
       fi

  - script:
     name: NoErrorTest - sevntu-checks
     code: |
       if [[ $RUN_JOB == 1 ]]; then
         echo "Command: ./.ci/wercker.sh no-error-sevntu-checks"
         ./.ci/wercker.sh no-error-sevntu-checks
       else
         echo "build is skipped ..."
       fi

  - script:
      name: NoExceptiontest - Apache Struts
      code: |
        if [[ $RUN_JOB == 1 ]]; then
          echo "Command: ./.ci/wercker.sh no-exception-struts"
          ./.ci/wercker.sh no-exception-struts
        else
          echo "build is skipped ..."
        fi

  - script:
      name: NoExceptiontest - Checkstyle ,sevntu-checkstyle
      code: |
        if [[ $RUN_JOB == 1 ]]; then
          echo "Command: ./.ci/wercker.sh no-exception-checkstyle-sevntu"
          ./.ci/wercker.sh no-exception-checkstyle-sevntu
        else
          echo "build is skipped ..."
        fi

  - script:
      name: NoExceptiontest - Guava
      code: |
        if [[ $RUN_JOB == 1 ]]; then
          echo "Command: ./.ci/wercker.sh ./.ci/wercker.sh no-exception-guava"
          ./.ci/wercker.sh no-exception-guava
        else
          echo "build is skipped ..."
        fi

  - script:
      name: NoExceptiontest - Hibernate
      code: |
        if [[ $RUN_JOB == 1 ]]; then
          echo "Command: ./.ci/wercker.sh no-exception-hibernate-orm"
          ./.ci/wercker.sh no-exception-hibernate-orm
        else
          echo "build is skipped ..."
        fi


  - script:
      name: NoExceptiontest - spotbugs
      code: |
        if [[ $RUN_JOB == 1 ]]; then
          echo "Command: ./.ci/wercker.sh no-exception-spotbugs"
          ./.ci/wercker.sh no-exception-spotbugs
        else
          echo "build is skipped ..."
        fi

  - script:
      name: NoExceptiontest - spring-framework
      code: |
        if [[ $RUN_JOB == 1 ]]; then
          echo "Command: ./.ci/wercker.sh no-exception-spring-framework"
          ./.ci/wercker.sh no-exception-spring-framework
        else
          echo "build is skipped ..."
        fi

  - script:
      name: NoExceptiontest - Hbase
      code: |
        if [[ $RUN_JOB == 1 ]]; then
          echo "Command: ./.ci/wercker.sh no-exception-hbase"
          ./.ci/wercker.sh no-exception-hbase
        else
          echo "build is skipped ..."
        fi

  - script:
      name: NoExceptiontest - pmd elasticsearch lombok-ast
      code: |
        if [[ $RUN_JOB == 1 ]]; then
          echo "Command: ./.ci/wercker.sh no-exception-Pmd-elasticsearch-lombok-ast"
          ./.ci/wercker.sh no-exception-Pmd-elasticsearch-lombok-ast
        else
          echo "build is skipped ..."
        fi

  - script:
      name: NoExceptiontest - RxJava apache-ant apache-jsecurity android-launcher ....
      code: |
        if [[ $RUN_JOB == 1 ]]; then
          echo "Command: ./.ci/wercker.sh no-exception-alot-of-projects"
          ./.ci/wercker.sh no-exception-alot-of-projects
        else
          echo "build is skipped ..."
        fi

  - script:
      name: NoWarningTest - guava imports ....
      code: |
        if [[ $RUN_JOB == 1 ]]; then
          echo "Command: ./.ci/wercker.sh no-warning-imports-guava"
          ./.ci/wercker.sh no-warning-imports-guava
        else
          echo "build is skipped ..."
        fi

  - script:
      name: NoWarningTest - java-design-patterns imports....
      code: |
        if [[ $RUN_JOB == 1 ]]; then
          echo "Command: ./.ci/wercker.sh no-warning-imports-java-design-patterns"
          ./.ci/wercker.sh no-warning-imports-java-design-patterns
        else
          echo "build is skipped ..."
        fi

  - script:
      name: Sonarqube validation
      code: |
        if [[ $RUN_JOB == 1 ]]; then
          echo "Command: ./.ci/wercker.sh sonarqube"
          ./.ci/wercker.sh sonarqube
        else
          echo "build is skipped ..."
        fi

  - script:
      name: Cleanup maven local repo
      code: |
        find ${WERCKER_CACHE_DIR} -type d -name "*SNAPSHOT" -ls -exec rm -rf {} +
        echo "------"
        du -hs ${WERCKER_CACHE_DIR}
        echo "------"
        du -hs ${WERCKER_CACHE_DIR}/* | sort -h
        echo "------"
        du -hs * | sort -h
