2011-08-19 09:21:51 +08:00
|
|
|
#! /bin/sh
|
2012-05-05 07:47:37 +08:00
|
|
|
# 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.
|
2011-08-19 09:21:51 +08:00
|
|
|
#
|
2012-02-02 09:45:49 +08:00
|
|
|
# create a cordova/android project
|
2011-08-19 09:21:51 +08:00
|
|
|
#
|
|
|
|
# USAGE
|
|
|
|
# ./create [path package activity]
|
|
|
|
#
|
2011-09-02 04:11:01 +08:00
|
|
|
set -e
|
|
|
|
|
2011-08-19 09:21:51 +08:00
|
|
|
PROJECT_PATH=${1:-"./example"}
|
2012-02-02 09:45:49 +08:00
|
|
|
PACKAGE=${2:-"org.apache.cordova.example"}
|
|
|
|
ACTIVITY=${3:-"cordovaExample"}
|
2011-09-08 07:31:29 +08:00
|
|
|
TARGET=$(android list targets | grep 'id: ' | sed 's/id: \([0-9]*\).*/\1/g' | tail -1)
|
2011-08-19 09:21:51 +08:00
|
|
|
VERSION=$(cat ./VERSION)
|
|
|
|
|
|
|
|
# clobber any existing example
|
|
|
|
if [ $# -eq 0 ]
|
|
|
|
then
|
|
|
|
rm -rf $PROJECT_PATH
|
|
|
|
fi
|
|
|
|
|
2012-02-02 09:45:49 +08:00
|
|
|
# update the cordova-android framework for the desired target
|
2011-08-21 04:27:53 +08:00
|
|
|
android update project --target $TARGET --path ./framework
|
|
|
|
|
2012-02-02 09:45:49 +08:00
|
|
|
# compile cordova.js and cordova.jar
|
2011-08-19 09:21:51 +08:00
|
|
|
cd ./framework && ant jar && cd ../
|
|
|
|
|
2011-08-27 01:54:37 +08:00
|
|
|
# copy all the bin scripts etc in there
|
|
|
|
cp -R ./bin/templates/project/ $PROJECT_PATH
|
2011-08-19 09:21:51 +08:00
|
|
|
|
2012-02-02 09:45:49 +08:00
|
|
|
# copy in cordova.js
|
|
|
|
cp ./framework/assets/www/cordova-$VERSION.js $PROJECT_PATH/.cordova/android/cordova-$VERSION.js
|
2011-08-19 09:21:51 +08:00
|
|
|
|
2012-02-02 09:45:49 +08:00
|
|
|
# copy in cordova.jar
|
|
|
|
cp ./framework/cordova-$VERSION.jar $PROJECT_PATH/.cordova/android/cordova-$VERSION.jar
|
2011-08-27 01:54:37 +08:00
|
|
|
|
2012-04-14 03:35:43 +08:00
|
|
|
# copy in res/xml
|
|
|
|
cp ./framework/res/xml/cordova.xml $PROJECT_PATH/.cordova/android/cordova.xml
|
|
|
|
cp ./framework/res/xml/plugins.xml $PROJECT_PATH/.cordova/android/plugins.xml
|
|
|
|
|
2011-08-27 01:54:37 +08:00
|
|
|
# app properties
|
2012-02-02 09:45:49 +08:00
|
|
|
cat > $PROJECT_PATH/.cordova/config <<eom
|
2011-08-27 01:54:37 +08:00
|
|
|
VERSION=$VERSION
|
|
|
|
PROJECT_PATH=$PROJECT_PATH
|
|
|
|
PACKAGE=$PACKAGE
|
|
|
|
ACTIVITY=$ACTIVITY
|
|
|
|
TARGET=$TARGET
|
|
|
|
eom
|
|
|
|
|
2012-02-02 09:45:49 +08:00
|
|
|
(cd $PROJECT_PATH && ./cordova/create)
|