git 获取android.jar

git clone git://git.source.android.com/platform/frameworks/base $SRC_DIR


#!/bin/sh

SRC_DIR=/tmp/android-api

print_syntax() {
echo "Syntax:/n/t$(basename $0) [option]"
echo "/nOptions:"
echo "/t-l prints available versions"
echo "/t-v builds jar file with sources of specified version"
echo "/t-c cleans up the sources from the temp directory/n"
exit 1
}

error() {
echo "Error:" $1
exit 1
}

download_sources() {
if [[ ! -d $SRC_DIR ]]; then
git clone git://git.source.android.com/platform/frameworks/base $SRC_DIR
fi
}

if ! which git > /dev/null ; then
error "git not installed (or not in the PATH)"
fi

if ! which jar > /dev/null ; then
error "jar not installed (or not in the PATH)"
fi

if [[ "$1" == "-l" ]]; then
download_sources
cd $SRC_DIR
git tag -l
exit 0;
fi

if [[ "$1" == "-c" ]]; then
rm -rf $SRC_DIR
exit 0;
fi

if [[ "$1" == "-v" && ! -z "$2" ]]; then
JAR_FILE=$(pwd)/$2-src.jar
download_sources
cd $SRC_DIR
if ! git tag -l | grep $2 ; then
echo "Version /"$2/" not found"
exit 1;
fi
git checkout $2
touch $JAR_FILE
find . -depth 2 -name "java" -type d -exec jar uf $JAR_FILE -C {} . /;
exit 0
fi

print_syntax
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值