Welcome 微信登录

首页 / 操作系统 / Linux / Android Java Jar包整合Shell脚本

Android Java Jar包整合Shell脚本用法:./my_script.sh android_root_path dist_full.jar脚本:#!/bin/bash# ./update_full_jar.sh android_root_dir ./dest_name.jar
#MYSRC=/home/baozaochao/work/_s7_eclair_svn_C00_bak/out/target/common/obj/JAVA_LIBRARIES/
#MYDST=/home/baozaochao/work/jars/dst/
MYDST=/tmp/__jar__temp/
ENDPATH=out/target/common/obj/JAVA_LIBRARIES/CUR_PATH=$PWDif [ ! -d "$1$ENDPATH" ];then
        echo The directory $1 is not root of the project.        
        echo The commond like ./update_full_jar.sh projectRootPath/ buildToPath/
        exit 1
fiMYSRC="$PWD"/$1$ENDPATH
echo $MYSRC
if [ "$2" = "" ];then
        echo The second parameter is required.
        echo The commond like ./update_full_jar.sh projectRootPath/ dest.jar
        exit 2
fi
JARDST=$2
JARDST="$PWD"/${JARDST%/}/
echo $JARDST#exit 0if [ -d "$MYDST" ];then
        rm -rf $MYDST
fi
mkdir $MYDST       cd $MYDST
for dir in `ls $MYSRC`
do
        if [ -d "$MYSRC$dir" ];then
                src="$MYSRC$dir"/classes.jar
                src2="$MYSRC$dir"/javalib.jar
                dst=$MYDST${dir%_intermediates}.jar
                if [ -f "$src" ];then
                        #echo #$src
                        cp $src $dst
                        jar xvf $dst
                        rm $dst -f
                        #break
                elif [ -f "$src2" ];then
                        echo $src2
                        cp $src2 $dst
                        jar xvf $dst
                        rm $dst -f
                        #break
                fi
        fi
done
jar cvf "$JARDST" * && echo **** Build "$JARDST" success. **** && rm -rf $MYDST