-
Notifications
You must be signed in to change notification settings - Fork 298
/
build-module.sh
executable file
·45 lines (37 loc) · 1.36 KB
/
build-module.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
#!/bin/bash
# compile specify module and copy to specify directory
version=$(head -n10 pom.xml | awk -F'[<>]' '/<version>/ {print $3; exit}')
function build_base() {
cd $SRC_DIR
mvn package -B --quiet -pl :addax-core,:addax-rdbms,:addax-storage,:addax-transformer -am -Dmaven.test.skip=true || exit 1
cp -a core/target/addax/* ${ADDAX_HOME}
rsync -azv lib/addax-{rdbms,storage,transformer}/target/addax/lib/* ${ADDAX_HOME}/lib/
}
if [ -z "$SRC_DIR" ]; then
SRC_DIR=$HOME/code/personal/Addax
fi
if [ -z "$ADDAX_HOME" ]; then
ADDAX_HOME=/opt/app/addax
fi
if [ -z $1 ]; then
echo "Usage: $0 module_name"
exit 1
fi
[ -d $ADDAX_HOME ] || mkdir -p $ADDAX_HOME || exit 1
[ -d $ADDAX_HOME/bin ] || build_base
MODULE_NAME=$1
cd $SRC_DIR
mvn package -B --quiet -pl :$MODULE_NAME -am -Dmaven.test.skip=true || exit 1
# if the module nam ends with reader, then the module base directory is plugin/reader,
# else the directory is plugin/writer
if [[ $MODULE_NAME =~ .*"reader" ]]; then
MODULE_DIR=plugin/reader
elif [[ $MODULE_NAME =~ .*"writer" ]]; then
MODULE_DIR=plugin/writer
else
echo "module name must end with reader or writer"
exit 1
fi
[ -d $ADDAX_HOME/$MODULE_DIR ] || mkdir -p $ADDAX_HOME/$MODULE_DIR || exit 1
cp -a $MODULE_DIR/$MODULE_NAME/target/${MODULE_NAME}-${version}/$MODULE_DIR/${MODULE_NAME} \
$ADDAX_HOME/$MODULE_DIR