summaryrefslogtreecommitdiff
path: root/scripts/android-standard-repo
blob: 7468e158d3e30d932e3099741badd10c87037206 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash

ERROR_MESSAGE="Error: The parameters --target, --path, --package, --activity, --name must be defined for an android-standard-repo\n"
HELP_MESSAGE="Usage: android-standard-repo [action options]\n
\n
 Options:\n
\t--name    : Project name. [required] \n
\t--target  : Target ID of the new project. [required]\n
\t--path    : The new project's directory. [required]\n
\t--package : Android package name for the application. [required]\n
\t--activity: Name of the default Activity that is created. [required]"

OPTS=`getopt -s bash -o aknpt -l activity: -l name: -l package: -l path: -l target: -- "$@"`
if [ $? != 0 ]
then
    exit 1
fi

eval set -- "$OPTS"

while [ "x$1" != "x" ] ; do
    case "$1" in
        --activity) ACTIVITY=$2; shift 2;;
        --name) NAME=$2; shift 2;;
        --package) PACKAGE=$2; shift 2;;
        --path) PROJECT_PATH=$2; shift 2;;
        --target) TARGET=$2; shift 2;;
        --) shift; break;;
    esac
done

if [ -z "$ACTIVITY" -o -z "$NAME" -o -z "$PACKAGE" -o -z "$PROJECT_PATH" -o -z "$TARGET" ]; then
    echo -e $ERROR_MESSAGE;
    echo -e $HELP_MESSAGE;
    exit
fi;

git init $PROJECT_PATH
cd $PROJECT_PATH
android create project --name $NAME --target $TARGET --path application --package $PACKAGE --activity $ACTIVITY
android create test-project --name Test$NAME --path tests --main ../application
echo "bin" >> .gitignore
echo "obj" >> .gitignore
echo "gen" >> .gitignore
echo "local.properties" >> .gitignore
echo "proguard-project.txt" >> .gitignore
git add *
git add .gitignore
git commit -a -m "Initial project structure"