build.sh 1013 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. #判断node.js mvn是否存在
  3. command -v npm >/dev/null 2>&1 || { echo >&2 "I require node.js v14.16.0+ but it's not installed. Aborting."; sleep 5; exit 1; }
  4. command -v mvn >/dev/null 2>&1 || { 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 $BuildDir
  8. echo "build web"
  9. cd $BuildDir/web
  10. npm install >/dev/null 2>&1
  11. npm run build:prod >/dev/null 2>&1
  12. echo "publish web to springboot src/main/resources/static"
  13. mkdir -p $BuildDir/java/sp-app/src/main/resources/static
  14. mv $BuildDir/web/dist/* $BuildDir/java/sp-app/src/main/resources/static/
  15. echo "build springboot"
  16. cd $BuildDir/java
  17. mvn clean >/dev/null 2>&1
  18. mvn package -Dmaven.test.skip=true -Dfile.encoding=UTF-8 >/dev/null 2>&1
  19. echo "zip finish in build dir"
  20. if [ ! -d "$BuildDir/build" ]; then
  21. mkdir $BuildDir/build
  22. fi
  23. mv $BuildDir/java/sp-app/target/sp-app-*.zip $BuildDir/build/
  24. rm -rf $BuildDir/java/sp-app/src/main/resources/static/*;