138 lines
5.1 KiB
Bash
138 lines
5.1 KiB
Bash
#! /bin/bash
|
||
# *****************************************************************************
|
||
# @author yxf
|
||
# @2015.01.04
|
||
# 执行这个文件一键打包
|
||
#
|
||
# 选项:
|
||
# -n 版本名 可选 不选的情况下,默认用旧的版本名
|
||
# -c 版本号 可选 不选的情况下,默认用旧的版本号
|
||
#
|
||
# 可选择是否关闭LOG开关
|
||
# *****************************************************************************
|
||
|
||
echo "Start......"
|
||
VERSIONCODE=
|
||
VERSIONNAME=
|
||
while getopts "c:n:" arg
|
||
do
|
||
case ${arg} in
|
||
c)
|
||
VERSIONCODE=${OPTARG}
|
||
;;
|
||
n)
|
||
VERSIONNAME=${OPTARG}
|
||
;;
|
||
?)
|
||
echo "unknown argument"
|
||
exit 1;
|
||
;;
|
||
esac
|
||
done
|
||
|
||
MAX_APPDEBUGCONFIG=1
|
||
MAX_VOLLEYLOG=1
|
||
MAX_DEBUG_VIEW=1
|
||
MAX_DEBUG_SDK=20
|
||
MAX_DEBUG_SDK_LOG=2
|
||
|
||
#这里修改各个文件
|
||
replaceSwitch()
|
||
{
|
||
#*****************************************************************************#
|
||
#*******************************AppDebugConfig.java***************************#
|
||
#*****************************************************************************#
|
||
effect_AppDebugConfig=$( sed -n '/true/p' app/src/com/oplay/android/config/AppDebugConfig.java | wc -l )
|
||
echo AppDebugConfig: effects ${effect_AppDebugConfig} lines.
|
||
if [ ${effect_AppDebugConfig} -le ${MAX_APPDEBUGCONFIG} ]; then
|
||
sed -i 's/true/false/g' app/src/com/oplay/android/config/AppDebugConfig.java
|
||
echo AppDebugConfig ....................................... OK
|
||
else
|
||
echo "AppDebugConfig ...................................... FAILED"
|
||
fi
|
||
|
||
#*****************************************************************************#
|
||
#*******************************VolleyLog.java********************************#
|
||
#*****************************************************************************#
|
||
effect_VolleyLog=$( sed -n '/DEBUG \?= \?true/p' libraries/Android-Volley/src/com/android/volley/VolleyLog.java | wc -l )
|
||
echo VolleyLog: effects ${effect_VolleyLog} lines.
|
||
if [ ${effect_VolleyLog} -le ${MAX_VOLLEYLOG} ]; then
|
||
sed -i 's/DEBUG \?= \?true/DEBUG = false/g' libraries/Android-Volley/src/com/android/volley/VolleyLog.java
|
||
echo VolleyLog ....................................... OK
|
||
else
|
||
echo "VolleyLog ...................................... FAILED"
|
||
fi
|
||
#*****************************************************************************#
|
||
#*******************************DebugView.java********************************#
|
||
#*****************************************************************************#
|
||
effect_Debug_View=$( sed -n '/true/p' libraries/YoumiUI/src/net/android/common/config/Debug_View.java | wc -l)
|
||
echo Debug_View: effects ${effect_Debug_View} lines.
|
||
if [ ${effect_VolleyLog} -le ${MAX_VOLLEYLOG} ]; then
|
||
sed -i 's/true/false/g' libraries/YoumiUI/src/net/android/common/config/Debug_View.java
|
||
echo Debug_View ....................................... OK
|
||
else
|
||
echo "Debug_View ...................................... FAILED"
|
||
fi
|
||
#*****************************************************************************#
|
||
#*******************************Debug_SDK.java********************************#
|
||
#*****************************************************************************#
|
||
effect_Debug_SDK=$( sed -n '/true/p' libraries/YoumiLibs/src/net/youmi/android/libs/common/debug/Debug_SDK.java | wc -l)
|
||
echo Debug_SDK: effects ${effect_Debug_SDK} lines.
|
||
if [ ${effect_VolleyLog} -le ${MAX_VOLLEYLOG} ]; then
|
||
sed -i 's/true/false/g' libraries/YoumiLibs/src/net/youmi/android/libs/common/debug/Debug_SDK.java
|
||
echo Debug_SDK ....................................... OK
|
||
else
|
||
echo "Debug_SDK ...................................... FAILED"
|
||
fi
|
||
|
||
#*****************************************************************************#
|
||
#*******************************Debug_SDK_Log.java****************************#
|
||
#*****************************************************************************#
|
||
effect_Debug_SDK_Log=$( sed -n '/= \?true/p' libraries/YoumiLibs/src/net/youmi/android/libs/common/debug/Debug_SDK_Log.java | wc -l)
|
||
echo Debug_SDK_Log: effects ${effect_Debug_SDK_Log} lines.
|
||
if [ ${effect_VolleyLog} -le ${MAX_VOLLEYLOG} ]; then
|
||
sed -i 's/= \?true/= false/g' libraries/YoumiLibs/src/net/youmi/android/libs/common/debug/Debug_SDK_Log.java
|
||
echo Debug_SDK_Log ....................................... OK
|
||
else
|
||
echo "Debug_SDK_Log ...................................... FAILED"
|
||
fi
|
||
}
|
||
replaceVersion()
|
||
{
|
||
if [ ${VERSIONCODE} ];then
|
||
sed -i "s/versionCode \?= \?[[:print:]]\{3,\}/versionCode = ${VERSIONCODE}/" build.gradle
|
||
echo VersionCode: ${VERSIONCODE} change Success.
|
||
fi
|
||
if [ ${VERSIONNAME} ];then
|
||
sed -i "s/versionName \?= \?[[:print:]]\{1,\}/versionName = \"${VERSIONNAME}\"/" build.gradle
|
||
echo VersionName: ${VERSIONNAME} change Success.
|
||
fi
|
||
}
|
||
|
||
build()
|
||
{
|
||
./gradlew clean assembleRelease -x lint --parallel
|
||
}
|
||
|
||
install()
|
||
{
|
||
adb install -r app/build/outputs/apk/app-release.apk
|
||
}
|
||
|
||
main()
|
||
{
|
||
replaceVersion;
|
||
read -p "是否要关闭LOG?(Y/y代表是,其它代表否)__" flag
|
||
if [ ${flag} ];then
|
||
if [ ${flag} = "y" ]||[ ${flag} = "Y" ]; then
|
||
replaceSwitch;
|
||
fi
|
||
fi
|
||
# read -p "ENTER键继续......"
|
||
# build;
|
||
# read -p "安装到机器上检查版本号,确认只有一台机器链接到服务器,确认旧版本已经删除,ENTER键继续......"
|
||
# install;
|
||
}
|
||
main;
|
||
|