#!/bin/bash

maven_setting=/Users/lanyuanxiaoyao/.m2/settings-nas.xml

build_profile=b2b12

upload_username=AxhEbscwsJDbYMH2
upload_password=cYxg3b4PtWoVD5SjFayWxtnSVsjzRsg4
upload_url=http://$upload_username:$upload_password@132.126.207.124:36800

root_path=$(dirname $(cd $(dirname $0);pwd))

function upload() {
  source_file_path=$(realpath $1)
  file_name=$(basename $source_file_path)
  echo "↪ Source md5: $(md5sum $source_file_path | awk '{print $1}')"
  echo "↪ Uploading $source_file_path"
  curl $upload_url/file/upload/$file_name -T $source_file_path
  echo "↪ Upload ytp success"
  echo "↪ Download: curl $upload_url/file/download/$file_name -o $file_name"
  echo "↪ Delete source"
  rm $source_file_path
}

function joining {
  local d=${1-} f=${2-}
  if shift 2; then
    printf %s "$f" "${@/#/$d}"
  fi
}

function deploy_root() {
    mvn deploy -N -D skipTests -s $maven_setting
}

function deploy() {
  mvn -pl $(joining , $@) clean deploy -D skipTests -s $maven_setting
}

function package() {
  mvn -pl $(joining , $@) clean package -D skipTests -P $build_profile -s $maven_setting
}
