mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-01 01:53:00 +08:00
refactoring android commands
This commit is contained in:
parent
a87825dbee
commit
0084c6f96a
@ -147,13 +147,12 @@ replace "s/__ACTIVITY__/${ACTIVITY}/g" "$MANIFEST_PATH"
|
|||||||
replace "s/__PACKAGE__/${PACKAGE}/g" "$MANIFEST_PATH"
|
replace "s/__PACKAGE__/${PACKAGE}/g" "$MANIFEST_PATH"
|
||||||
replace "s/__APILEVEL__/${API_LEVEL}/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
|
mkdir "$PROJECT_PATH"/cordova
|
||||||
createAppInfoJar
|
createAppInfoJar
|
||||||
cp "$BUILD_PATH"/bin/templates/cordova/appinfo.jar "$PROJECT_PATH"/cordova/appinfo.jar
|
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/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/clean "$PROJECT_PATH"/cordova/clean
|
||||||
cp "$BUILD_PATH"/bin/templates/cordova/log "$PROJECT_PATH"/cordova/log
|
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/run "$PROJECT_PATH"/cordova/run
|
||||||
cp "$BUILD_PATH"/bin/templates/cordova/BOOM "$PROJECT_PATH"/cordova/BOOM
|
|
||||||
|
BIN
bin/templates/cordova/ApplicationInfo/ApplicationInfo.class
Normal file
BIN
bin/templates/cordova/ApplicationInfo/ApplicationInfo.class
Normal file
Binary file not shown.
BIN
bin/templates/cordova/appinfo.jar
Normal file
BIN
bin/templates/cordova/appinfo.jar
Normal file
Binary file not shown.
@ -21,4 +21,4 @@ set -e
|
|||||||
|
|
||||||
CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd )
|
CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd )
|
||||||
|
|
||||||
bash "$CORDOVA_PATH"/cordova debug
|
bash "$CORDOVA_PATH"/cordova build
|
@ -15,4 +15,4 @@
|
|||||||
:: specific language governing permissions and limitations
|
:: specific language governing permissions and limitations
|
||||||
:: under the License.
|
:: under the License.
|
||||||
|
|
||||||
%~dp0\cordova.bat BOOM
|
%~dp0\cordova.bat build
|
@ -22,7 +22,7 @@ set -e
|
|||||||
PROJECT_PATH=$( cd "$( dirname "$0" )/.." && pwd )
|
PROJECT_PATH=$( cd "$( dirname "$0" )/.." && pwd )
|
||||||
|
|
||||||
function check_devices {
|
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
|
if [ -z "$devices" ] ; then
|
||||||
echo "1"
|
echo "1"
|
||||||
else
|
else
|
||||||
@ -37,7 +37,7 @@ function emulate {
|
|||||||
|
|
||||||
# Do not launch an emulator if there is already one running or if a device is attached
|
# Do not launch an emulator if there is already one running or if a device is attached
|
||||||
if [ $(check_devices) == 0 ] ; then
|
if [ $(check_devices) == 0 ] ; then
|
||||||
echo "Device attached or emulator already running"
|
# echo "Device attached or emulator already running"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -78,25 +78,40 @@ function log {
|
|||||||
adb logcat
|
adb logcat
|
||||||
}
|
}
|
||||||
|
|
||||||
function debug {
|
function run {
|
||||||
if [ $(check_devices) == 0 ] ; then
|
if [ $(check_devices) == 0 ] ; then
|
||||||
ant debug install
|
clean && emulate && install && launch
|
||||||
else
|
else
|
||||||
ant debug
|
build
|
||||||
echo "##################################################################"
|
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 "##################################################################"
|
echo "##################################################################"
|
||||||
fi
|
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 {
|
function launch {
|
||||||
local launch_str=$(java -jar "$PROJECT_PATH"/cordova/appinfo.jar "$PROJECT_PATH"/AndroidManifest.xml)
|
local launch_str=$(java -jar "$PROJECT_PATH"/cordova/appinfo.jar "$PROJECT_PATH"/AndroidManifest.xml)
|
||||||
adb shell am start -n $launch_str
|
adb shell am start -n $launch_str
|
||||||
}
|
}
|
||||||
|
|
||||||
function BOOM {
|
|
||||||
clean && debug && launch
|
|
||||||
}
|
|
||||||
|
|
||||||
# TODO parse arguments
|
# TODO parse arguments
|
||||||
(cd "$PROJECT_PATH" && $1)
|
(cd "$PROJECT_PATH" && $1)
|
||||||
|
@ -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
|
|
@ -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
|
|
@ -1 +0,0 @@
|
|||||||
%~dp0\cordova.bat emulate
|
|
@ -21,4 +21,4 @@ set -e
|
|||||||
|
|
||||||
CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd )
|
CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd )
|
||||||
|
|
||||||
bash $CORDOVA_PATH/cordova BOOM
|
bash "$CORDOVA_PATH"/cordova run
|
1
bin/templates/cordova/run.bat
Normal file
1
bin/templates/cordova/run.bat
Normal file
@ -0,0 +1 @@
|
|||||||
|
%~dp0\cordova.bat run
|
Loading…
Reference in New Issue
Block a user