cordova-android/bin/templates/project/cordova/create
2012-02-03 10:38:40 -05:00

37 lines
1.1 KiB
Bash
Executable File

#! /bin/sh
#
# create a cordova/android project
#
# USAGE
# ./create [path package activity]
#
# load up the config
. ./.cordova/config
PACKAGE_AS_PATH=$(echo $PACKAGE | sed 's/\./\//g')
ACTIVITY_PATH=./src/$PACKAGE_AS_PATH/$ACTIVITY.java
MANIFEST_PATH=./AndroidManifest.xml
# create the project
android create project --target $TARGET --path . --package $PACKAGE --activity $ACTIVITY
# copy all the cordova scripts etc in there
cp -R ./cordova/templates/project/* .
# copy in cordova.js
cp ./.cordova/android/cordova-$VERSION.js ./assets/www
# copy in cordova.jar
cp ./.cordova/android/cordova-$VERSION.jar ./libs
# copy in default activity
cat ./cordova/templates/Activity.java > $ACTIVITY_PATH
# interpolate the acivity name and package
find "$ACTIVITY_PATH" | xargs grep '__ACTIVITY__' -sl | xargs -L1 sed -i -e "s/__ACTIVITY__/${ACTIVITY}/g"
find "$ACTIVITY_PATH" | xargs grep '__ID__' -sl | xargs -L1 sed -i -e "s/__ID__/${PACKAGE}/g"
find "$MANIFEST_PATH" | xargs grep '__ACTIVITY__' -sl | xargs -L1 sed -i -e "s/__ACTIVITY__/${ACTIVITY}/g"
find "$MANIFEST_PATH" | xargs grep '__PACKAGE__' -sl | xargs -L1 sed -i -e "s/__PACKAGE__/${PACKAGE}/g"