build.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/bash
  2. echo "判断node.js mvn是否存在"
  3. command -v npm || { echo >&2 "I require node.js v14.16.0+ but it's not installed. Aborting."; sleep 5; exit 1; }
  4. command -v mvn || { echo >&2 "I require maven 3.5 + but it's not installed. Aborting."; sleep 5; exit 1; }
  5. cd `dirname $0`
  6. BuildDir=`pwd` #工程根目录
  7. echo "build web"
  8. cd $BuildDir/report-ui
  9. echo "npm install"
  10. npm install
  11. if [ $? -ne 0 ]; then
  12. npm install --registry=https://mirrors.cloud.tencent.com/npm/
  13. fi
  14. echo "cp echarts map js"
  15. cp -r node_modules_echarts_need/* node_modules/echarts/
  16. echo "npm run build"
  17. npm run build:prod
  18. echo "publish web to springboot src/main/resources/static"
  19. rm -rf $BuildDir/report-core/src/main/resources/static
  20. mkdir -p $BuildDir/report-core/src/main/resources/static
  21. if [ ! -e "$BuildDir/report-ui/dist" ];then
  22. echo "no build dist exist,web-build-failed"
  23. exit 1
  24. fi
  25. echo ""
  26. cp -r $BuildDir/report-ui/dist/* $BuildDir/report-core/src/main/resources/static/
  27. echo "build springboot"
  28. cd $BuildDir/report-core
  29. echo "mvn clean package"
  30. mvn clean package -Dmaven.test.skip=true
  31. echo "zip finish in build dir"
  32. if [ ! -d "$BuildDir/build" ]; then
  33. mkdir $BuildDir/build
  34. fi
  35. mv $BuildDir/report-core/target/aj-report-*.zip $BuildDir/build/
  36. rm -rf $BuildDir/report-core/src/main/resources/static/*
  37. echo "Finish"