-
Notifications
You must be signed in to change notification settings - Fork 23
/
build.sh
100 lines (82 loc) · 2.23 KB
/
build.sh
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/sh
BUILD_DIRECTORY=$1
USER_NAME=$2
DEPLOY=$3
BRANCH=$4
PROJECT_NAME=jdroid
# Help
# ****
if [ $# -eq 1 ] && [ $1 = -h ]
then
echo "Help"
echo "****"
echo ""
echo "This script will build the application."
echo "Available parameters"
echo ""
echo " 1) The path to a directory where the code will be checked out and the assemblies would be generated. For example: /home/user/build. Required."
echo ""
echo " 2) The Git user name used to checkout the code. Required."
echo ""
echo " 3) Whether the assemblies should be deployed or not. Optional. Default value: false"
echo ""
echo " 4) The branch from where check out the code. Optional. Default value: master"
echo ""
exit 0
fi
# Parameters validation
# ************************
if [ -z "$BUILD_DIRECTORY" ]
then
echo "[ERROR] The BUILD_DIRECTORY parameter is required"
echo "Run the script with '-h' for help"
exit 1;
fi
if [ ! -d "$BUILD_DIRECTORY" ]
then
echo "[ERROR] - The BUILD_DIRECTORY directory does not exist."
echo "Run the script with '-h' for help"
exit 1;
fi
if [ -z "$USER_NAME" ]
then
echo "[ERROR] The USER_NAME parameter is required"
echo "Run the script with '-h' for help"
exit 1
fi
if [ -z "$DEPLOY" ]
then
DEPLOY="false"
fi
if [ -z "$BRANCH" ]
then
BRANCH=master
fi
SOURCE_DIRECTORY=$BUILD_DIRECTORY/$PROJECT_NAME/source
ASSEMBLIES_DIRECTORY=$BUILD_DIRECTORY/$PROJECT_NAME/assemblies
# Checking out
# ************************
# Clean the directories
rm -r -f $SOURCE_DIRECTORY
mkdir -p $SOURCE_DIRECTORY
rm -r -f $ASSEMBLIES_DIRECTORY
mkdir -p $ASSEMBLIES_DIRECTORY
# Checkout the project
cd $SOURCE_DIRECTORY
echo Cloning [email protected]:maxirosson/jdroid.git
git clone [email protected]:maxirosson/jdroid.git $PROJECT_NAME
cd $SOURCE_DIRECTORY/$PROJECT_NAME
if [ "$BRANCH" != 'master' ]
then
git checkout -b $BRANCH origin/$BRANCH --track
fi
# Assemblies Generation
# ************************
cd $SOURCE_DIRECTORY/$PROJECT_NAME
mvn dependency:resolve clean install -Dmaven.test.skip=true
if [ "$DEPLOY" = "true" ]
then
mvn javadoc:aggregate
mvn deploy assembly:single -Dmaven.test.skip=true
cp ./target/*.zip $ASSEMBLIES_DIRECTORY/
fi