Allow for predefined ANDROID_BIN value, fix for paths with spaces

This commit is contained in:
Joshua Granick 2012-08-13 15:56:54 -07:00 committed by Andrew Grieve
parent da8fbee256
commit 1bf12842ca

View File

@ -30,10 +30,10 @@ then
exit 0
fi
BUILD_PATH=$( cd "$( dirname "$0" )/.." && pwd )
BUILD_PATH="$( cd "$( dirname "$0" )/.." && pwd )"
VERSION=$(cat "$BUILD_PATH"/VERSION)
PROJECT_PATH=${1:-'./example'}
PROJECT_PATH="${1:-'./example'}"
PACKAGE=${2:-"org.apache.cordova.example"}
ACTIVITY=${3:-"cordovaExample"}
@ -87,19 +87,20 @@ function replace {
trap on_error ERR
trap on_exit EXIT
ANDROID_BIN=$( which android )
ANDROID_BIN="${ANDROID_BIN:=$( which android )}"
PACKAGE_AS_PATH=$(echo $PACKAGE | sed 's/\./\//g')
ACTIVITY_PATH="$PROJECT_PATH"/src/$PACKAGE_AS_PATH/$ACTIVITY.java
MANIFEST_PATH="$PROJECT_PATH"/AndroidManifest.xml
TARGET=$($ANDROID_BIN list targets | grep id: | tail -1 | cut -f 2 -d ' ' )
API_LEVEL=$($ANDROID_BIN list target | grep "API level:" | tail -n 1 | awk '{gsub(" API level:", "");print}' | cut -f 2 -d ' ')
TARGET=$("$ANDROID_BIN" list targets | grep id: | tail -1 | cut -f 2 -d ' ' )
API_LEVEL=$("$ANDROID_BIN" list target | grep "API level:" | tail -n 1 | awk '{gsub(" API level:", "");print}' | cut -f 2 -d ' ')
# if this a distribution release no need to build a jar
if [ ! -e "$BUILD_PATH"/cordova-$VERSION.jar ] && [ -d "$BUILD_PATH"/framework ]
then
# update the cordova-android framework for the desired target
$ANDROID_BIN update project --target $TARGET --path "$BUILD_PATH"/framework &> /dev/null
"$ANDROID_BIN" update project --target $TARGET --path "$BUILD_PATH"/framework &> /dev/null
if [ ! -e "$BUILD_PATH"/framework/libs/commons-codec-1.7.jar ]; then
# Use curl to get the jar (TODO: Support Apache Mirrors)
@ -116,7 +117,7 @@ then
fi
# create new android project
$ANDROID_BIN create project --target $TARGET --path "$PROJECT_PATH" --package $PACKAGE --activity $ACTIVITY &> /dev/null
"$ANDROID_BIN" create project --target $TARGET --path "$PROJECT_PATH" --package $PACKAGE --activity $ACTIVITY &> /dev/null
# copy project template
cp -r "$BUILD_PATH"/bin/templates/project/assets "$PROJECT_PATH"