refactoring android commands

This commit is contained in:
Anis Kadri 2012-11-20 14:39:33 -08:00 committed by Simon MacDonald
parent a87825dbee
commit 0084c6f96a
11 changed files with 32 additions and 60 deletions

View File

@ -147,13 +147,12 @@ replace "s/__ACTIVITY__/${ACTIVITY}/g" "$MANIFEST_PATH"
replace "s/__PACKAGE__/${PACKAGE}/g" "$MANIFEST_PATH"
replace "s/__APILEVEL__/${API_LEVEL}/g" "$MANIFEST_PATH"
# creating cordova folder and copying emulate/debug/log/launch scripts
# creating cordova folder and copying run/build/log/launch scripts
mkdir "$PROJECT_PATH"/cordova
createAppInfoJar
cp "$BUILD_PATH"/bin/templates/cordova/appinfo.jar "$PROJECT_PATH"/cordova/appinfo.jar
cp "$BUILD_PATH"/bin/templates/cordova/cordova "$PROJECT_PATH"/cordova/cordova
cp "$BUILD_PATH"/bin/templates/cordova/debug "$PROJECT_PATH"/cordova/debug
cp "$BUILD_PATH"/bin/templates/cordova/build "$PROJECT_PATH"/cordova/build
cp "$BUILD_PATH"/bin/templates/cordova/clean "$PROJECT_PATH"/cordova/clean
cp "$BUILD_PATH"/bin/templates/cordova/log "$PROJECT_PATH"/cordova/log
cp "$BUILD_PATH"/bin/templates/cordova/emulate "$PROJECT_PATH"/cordova/emulate
cp "$BUILD_PATH"/bin/templates/cordova/BOOM "$PROJECT_PATH"/cordova/BOOM
cp "$BUILD_PATH"/bin/templates/cordova/run "$PROJECT_PATH"/cordova/run

Binary file not shown.

View File

@ -21,4 +21,4 @@ set -e
CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd )
bash "$CORDOVA_PATH"/cordova debug
bash "$CORDOVA_PATH"/cordova build

View File

@ -15,4 +15,4 @@
:: specific language governing permissions and limitations
:: under the License.
%~dp0\cordova.bat BOOM
%~dp0\cordova.bat build

View File

@ -22,7 +22,7 @@ set -e
PROJECT_PATH=$( cd "$( dirname "$0" )/.." && pwd )
function check_devices {
local devices=`adb devices | awk '/List of devices attached/ { while(getline > 0) { print }}'`
local devices=`adb devices | awk '/List of devices attached/ { while(getline > 0) { print }}' | grep device`
if [ -z "$devices" ] ; then
echo "1"
else
@ -37,7 +37,7 @@ function emulate {
# Do not launch an emulator if there is already one running or if a device is attached
if [ $(check_devices) == 0 ] ; then
echo "Device attached or emulator already running"
# echo "Device attached or emulator already running"
return
fi
@ -78,25 +78,40 @@ function log {
adb logcat
}
function debug {
function run {
if [ $(check_devices) == 0 ] ; then
ant debug install
clean && emulate && install && launch
else
ant debug
build
echo "##################################################################"
echo "# Plug in your device or launch an emulator with cordova/emulate #"
echo "# Plug in your device or launch an emulator with cordova/run #"
echo "##################################################################"
fi
}
function install {
ant debug install
}
function build {
ant debug
}
function wait_for_device {
local i=0
echo "Waiting for emulator..."
while [ check_devices -eq 0 || timeout -lt 300 ]
do
sleep 1
i=$[i+1]
end
}
function launch {
local launch_str=$(java -jar "$PROJECT_PATH"/cordova/appinfo.jar "$PROJECT_PATH"/AndroidManifest.xml)
adb shell am start -n $launch_str
}
function BOOM {
clean && debug && launch
}
# TODO parse arguments
(cd "$PROJECT_PATH" && $1)

View File

@ -1,18 +0,0 @@
:: Licensed to the Apache Software Foundation (ASF) under one
:: or more contributor license agreements. See the NOTICE file
:: distributed with this work for additional information
:: regarding copyright ownership. The ASF licenses this file
:: to you under the Apache License, Version 2.0 (the
:: "License"); you may not use this file except in compliance
:: with the License. You may obtain a copy of the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing,
:: software distributed under the License is distributed on an
:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
:: KIND, either express or implied. See the License for the
:: specific language governing permissions and limitations
:: under the License.
%~dp0\cordova.bat debug

View File

@ -1,24 +0,0 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#!/bin/bash
set -e
CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd )
bash "$CORDOVA_PATH"/cordova emulate

View File

@ -1 +0,0 @@
%~dp0\cordova.bat emulate

View File

@ -21,4 +21,4 @@ set -e
CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd )
bash $CORDOVA_PATH/cordova BOOM
bash "$CORDOVA_PATH"/cordova run

View File

@ -0,0 +1 @@
%~dp0\cordova.bat run