shell脚本执行maven编译命令(支持jdk和项目路径作为参数)

shell脚本(可用于项目编译平台,支持众多项目的个性化编译):

if [ x$1 == x ]; then
  echo default jdk1.6
  exit 0
fi

if [ x$1 == x1.7 ]; then
  echo change jdk to 1.7
  export JAVA_HOME=/source/jdk/jdk1.7.0_79
  export JRE_HOME=$JAVA_HOME/jre
  export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
  export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
  java -version
  cd $2
  mvn clean
  mvn compile
  mvn package
fi

if [ x$1 == x1.8 ]; then
  echo change jdk to 1.8
  export JAVA_HOME=/source/jdk/jdk1.8.0_121
  export JRE_HOME=$JAVA_HOME/jre
  export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
  export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
  java -version
  cd $2
  mvn clean
  mvn compile
  mvn package
fi

执行脚本命令:/source/onlinecompile.sh 1.7 /source/code/cluster/ >> /source/11.log

posted @ 2019-03-12 11:35  忘聊寒  阅读(2641)  评论(0编辑  收藏  举报