#!/bin/sh
#!/bin/bash
old_dir=`pwd`
cd `dirname $0`
#进入项目上层目录
cd ..
path=`pwd`
logFile="$path/log-builall.log"
files=$(ls $path)
echo "path is $path"
echo "Ctrl+C退出当前Module编译"
echo "两秒钟后即将开始"
sleep 2
printMsg(){
echo "$1"
echo "$1" >> $logFile
}
runBuildAll(){
echo "" > $logFile
cmd_open_other_terminal='tell application "Terminal"
do script "_other_terminal_run_"
end tell'
_other_terminal_run_="tail -f ${logFile}"
cmd_open_other_terminal_result=${cmd_open_other_terminal/_other_terminal_run_/${_other_terminal_run_}}
echo "cmd_open_other_terminal_result is : "
echo "${cmd_open_other_terminal_result}"
echo
sleep 1
osascript -e "${cmd_open_other_terminal_result}"
for filename in $files
do
if [ -d $filename ];then
if [[ "$filename" =~ "dsm" ]];then
continue
fi
echo
printMsg "==============================buildall================================"
printMsg "==============================${filename}=============================="
printMsg "======================================================================="
printMsg
cd $filename
local taskPre
if [[ "$filename" =~ "2016" ]];then
taskPre="app"
else
taskPre="sample"
fi
printMsg "****打包进行中,详细日志见 $logFile ****"
printMsg
./gradlew "${taskPre}:clean" "${taskPre}:assembleRelease" >> "$logFile" 2>&1
printMsg "-----------------------结束-------------------------"
printMsg
printMsg
printMsg "回根目录"
cd $path
sleep 1
fi
done
}
runBuildAll
cd $old_dir