#!/bin/bash

###############################################################################
# tnb 模块作为其他模块(应用)的依赖 install 到本地仓库或 deploy 到远程仓库
###############################################################################

set -e

proj_dir="${HOME}/code/java/tnb"

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

 #cd ~/code/java/tnb/tinyurl/
 #mvn clean install -am -Dmaven.test.skip -pl tinyurl-api/
}

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

  #cd ~/code/java/tnb/tinyurl/
  #mvn clean deploy -am -Dmaven.test.skip -pl tinyurl-api/
}

#echo "install dependencies on local repo..."
#install_dependencies

echo "deploy dependencies on remote repo..."
deploy_dependencies
