Added REST functionality for the Bill. RabbitMQProducer was refined. UserActor sends...
[aquarium] / make-dist.sh
index 3e458c2..144384f 100755 (executable)
@@ -48,6 +48,9 @@ P_PROPS=""
 P_BUILD="normal"
 P_KEEPDIST="no"
 P_FAKEIT="no"
+P_ARCHIVE=""
+P_OFFLINE="no"
+MVN_OPTS=""
 
 verbose() {
   if [ "$P_VERBOSE" = "yes" ]; then
@@ -59,7 +62,9 @@ verbose_p() {
   verbose "Build type          :" $P_BUILD
   verbose "Custom configuration:" $P_PROPS
   verbose "Keep dist/ folder   :" $P_KEEPDIST
+  verbose "Custom achive name  :" $P_ARCHIVE
   verbose "Fake it             :" $P_FAKEIT
+  verbose "maven offline mode  :" $P_OFFLINE
 }
 
 fail() {
@@ -67,6 +72,12 @@ fail() {
     exit 1
 }
 
+makedistname() {
+  if [ -n "$P_ARCHIVE" ]; then
+    DIST="$P_ARCHIVE"
+  fi
+}
+
 removedist() {
   local KEEP=$1
   if [ "$KEEP" = "no" -a -e $DIST ]; then
@@ -93,7 +104,8 @@ clean() {
     echo "=== mvn clean ================="
     echo "==============================="
     echo
-    mvn clean || fail "cleaning compilation artifacts"
+    echo mvn ${MVN_OPTS} clean
+    mvn ${MVN_OPTS} clean || fail "cleaning compilation artifacts"
     echo
   elif [ "$P_BUILD"="fast" ]; then
     echo
@@ -105,7 +117,12 @@ clean() {
 }
 
 collectdeps() {
-  mvn dependency:copy-dependencies && cp target/dependency/*.jar $DIST/lib || fail "collecting dependencies"
+  if [ "$P_BUILD" = "normal" ]; then
+    echo mvn ${MVN_OPTS} dependency:copy-dependencies
+    mvn ${MVN_OPTS} dependency:copy-dependencies
+  fi
+
+  cp target/dependency/*.jar $DIST/lib || fail "collecting dependencies"
 }
 
 build() {
@@ -114,7 +131,8 @@ build() {
   echo "=== mvn package ==============="
   echo "==============================="
   echo
-  mvn package -DskipTests && {
+  echo mvn ${MVN_OPTS} package -DskipTests
+  mvn ${MVN_OPTS} package -DskipTests && {
     echo
     echo "Copying Aquarium classes"
     aquariumjar=`find target -type f|egrep "aquarium-[0-9\.]+(-SNAPSHOT)?\.jar"`
@@ -126,9 +144,8 @@ collectconf() {
   echo
   echo Copying config files from $CONF_SRC
   echo
-  cp $CONF_SRC/logback.xml $DIST/conf|| fail "copying logback.xml"
-  cp $CONF_SRC/policy.yaml $DIST/conf || fail "copying policy.yaml"
-  cp $CONF_SRC/roles-agreements.map $DIST/conf || fail "copying roles-agreements.map"
+  cp $CONF_SRC/policy.json $DIST/conf          || fail "copying policy.json"
+#  cp $CONF_SRC/roles-agreements.map $DIST/conf || fail "copying roles-agreements.map"
 
   if [ -n "$P_PROPS" ]; then
     cp $P_PROPS $DIST/conf/aquarium.properties || fail "copying $P_PROPS"
@@ -144,7 +161,6 @@ collectscripts() {
   cp $SERVER_SCRIPTS_SRC/aquarium.sh $DIST/bin || fail "copying aquarium.sh"
   cp $SERVER_SCRIPTS_SRC/start.sh $DIST/bin || fail "copying start.sh"
   cp $SERVER_SCRIPTS_SRC/stop.sh $DIST/bin || fail "copying stop.sh"
-  cp $SERVER_SCRIPTS_SRC/test.sh $DIST/bin || fail "copying test.sh"
 }
 
 gitmark() {
@@ -152,23 +168,27 @@ gitmark() {
 }
 
 archive() {
-  ARC=$DIST.tar.gz
+  ARC="${DIST}.tar.gz"
+
   if [ -e "$ARC" ]; then
     echo
     echo Removing previous $ARC
+    rm "$ARC"
   fi
   echo
   echo "Creating archive"
-  tar zcvf $ARC $DIST/ || fail "creating archive"
+  tar zcvf "$ARC" $DIST/ || fail "creating archive"
   echo "File $ARC created succesfully"
   echo "Cleaning up"
-  ls -al $ARC
+  ls -al "$ARC"
 }
 
 usage() {
   echo "Usage: $0 [options]"
   echo ""
   echo "OPTIONS:"
+  echo "  -a NAME   Use archive NAME."
+  echo "            The full name will be NAME.tar.gz."
   echo "  -b TYPE   Use build TYPE. One of 'normal', 'fast'."
   echo "            'normal' is the default and can be omitted."
   echo "            'fast' means that it will not run mvn clean."
@@ -176,14 +196,17 @@ usage() {
   echo "  -k        Keep generated dist folder."
   echo "  -h        Show this message."
   echo "  -n        As in make -n."
+  echo "  -o        Use mvn in offline mode (--offline, -o)"
   echo "  -v        Be verbose."
 
   exit 0
 }
 
-while getopts ":b:hkc:nv" opt
+while getopts ":a:b:hkc:nov" opt
 do
   case $opt in
+    a) P_ARCHIVE=$OPTARG
+    ;;
     b) P_BUILD=$OPTARG
     ;;
     c) P_PROPS=$OPTARG
@@ -194,6 +217,8 @@ do
     ;;
     n) P_FAKEIT="yes"
     ;;
+    o) P_OFFLINE="yes"; MVN_OPTS="-o"
+    ;;
     v) P_VERBOSE="yes"
     ;;
     :) ERROR="Option -$OPTARG requires an argument. Aborting..."
@@ -224,6 +249,7 @@ if [ "$P_FAKEIT" = "yes" ]; then
 fi
 
 verbose_p         && \
+makedistname      && \
 removedist     no && \
 createdist        && \
 clean             && \
@@ -233,4 +259,4 @@ collectconf       && \
 collectscripts    && \
 gitmark           && \
 archive           && \
-removedist $P_KEEPDIST
\ No newline at end of file
+removedist $P_KEEPDIST