#!/bin/bash

###############################################################################
# 构建 tnb 应用
###############################################################################

set -e

proj_dir=`pwd`

install_dependencies() {
  cd ${proj_dir}
  mvn clean install -Dmaven.test.skip -am -pl common
  mvn clean install -Dmaven.test.skip -am -pl common-auth
  mvn clean install -Dmaven.test.skip -am -pl auth/auth-api/
  mvn clean install -Dmaven.test.skip -am -pl user/user-api/
  mvn clean install -Dmaven.test.skip -am -pl message/message-api/
  mvn clean install -Dmaven.test.skip -am -pl content/content-api/
  mvn clean install -Dmaven.test.skip -am -pl file/file-api/
  mvn clean install -Dmaven.test.skip -am -pl search/search-api/
  mvn clean install -Dmaven.test.skip -am -pl data/data-api/
}

deploy_dependencies() {
  cd ${proj_dir}
  mvn clean deploy -Dmaven.test.skip -am -pl common
  mvn clean deploy -Dmaven.test.skip -am -pl common-auth
  mvn clean deploy -Dmaven.test.skip -am -pl auth/auth-api/
  mvn clean deploy -Dmaven.test.skip -am -pl user/user-api/
  mvn clean deploy -Dmaven.test.skip -am -pl message/message-api/
  mvn clean deploy -Dmaven.test.skip -am -pl content/content-api/
  mvn clean deploy -Dmaven.test.skip -am -pl file/file-api/
  mvn clean deploy -Dmaven.test.skip -am -pl search/search-api/
  mvn clean deploy -Dmaven.test.skip -am -pl data/data-api/
}

echo "安装 tnb 依赖到本地仓库..."
install_dependencies

echo "部署 tnb 依赖到远程仓库..."
#deploy_dependencies