You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2012/09/27 20:05:59 UTC

android commit: Allow for predefined ANDROID_BIN value, fix for paths with spaces

Updated Branches:
  refs/heads/master da8fbee25 -> 1bf12842c


Allow for predefined ANDROID_BIN value, fix for paths with spaces


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/1bf12842
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/1bf12842
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/1bf12842

Branch: refs/heads/master
Commit: 1bf12842caab98ae8ecddb9520317df86e068efd
Parents: da8fbee
Author: Joshua Granick <jo...@joshuagranick.com>
Authored: Mon Aug 13 15:56:54 2012 -0700
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Sep 27 14:05:01 2012 -0400

----------------------------------------------------------------------
 bin/create |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/1bf12842/bin/create
----------------------------------------------------------------------
diff --git a/bin/create b/bin/create
index 2f6c018..958a030 100755
--- a/bin/create
+++ b/bin/create
@@ -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"