Fix compilation of tests
[aquarium] / make-dist.sh
index 600d6cd..a80fd4b 100755 (executable)
@@ -48,6 +48,7 @@ P_PROPS=""
 P_BUILD="normal"
 P_KEEPDIST="no"
 P_FAKEIT="no"
+P_ARCHIVE=""
 
 verbose() {
   if [ "$P_VERBOSE" = "yes" ]; then
@@ -56,10 +57,11 @@ verbose() {
 }
 
 verbose_p() {
-  verbose "Build type       :" $P_BUILD
-  verbose "Custom properties:" $P_PROPS
-  verbose "Keep dist/ folder:" $P_KEEPDIST
-  verbose "Fake it          :" $P_FAKEIT
+  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
 }
 
 fail() {
@@ -67,6 +69,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
@@ -105,7 +113,11 @@ clean() {
 }
 
 collectdeps() {
-  mvn dependency:copy-dependencies && cp target/dependency/*.jar $DIST/lib || fail "collecting dependencies"
+  if [ "$P_BUILD" = "normal" ]; then
+    mvn dependency:copy-dependencies
+  fi
+
+  cp target/dependency/*.jar $DIST/lib || fail "collecting dependencies"
 }
 
 build() {
@@ -126,7 +138,7 @@ collectconf() {
   echo
   echo Copying config files from $CONF_SRC
   echo
-  cp $CONF_SRC/log4j.properties $DIST/conf|| fail "copying log4j.properties"
+  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"
 
@@ -142,6 +154,8 @@ collectscripts() {
   echo Copying scripts from $SERVER_SCRIPTS_SRC
   echo
   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"
 }
 
@@ -150,44 +164,54 @@ 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."
+  echo "  -c FILE   Use FILE as aquarium.properties configuration."
   echo "  -k        Keep generated dist folder."
   echo "  -h        Show this message."
   echo "  -n        As in make -n."
-  echo "  -p FILE   Use FILE as aquarium.properties."
   echo "  -v        Be verbose."
 
   exit 0
 }
 
-while getopts ":b:hkp:nv" opt
+while getopts ":a:b:hkc:nv" opt
 do
   case $opt in
+    a) P_ARCHIVE=$OPTARG
+    ;;
     b) P_BUILD=$OPTARG
     ;;
+    c) P_PROPS=$OPTARG
+    ;;
     h) usage
     ;;
     k) P_KEEPDIST="yes"
     ;;
     n) P_FAKEIT="yes"
     ;;
-    p) P_PROPS=$OPTARG
-    ;;
     v) P_VERBOSE="yes"
     ;;
     :) ERROR="Option -$OPTARG requires an argument. Aborting..."
@@ -218,6 +242,7 @@ if [ "$P_FAKEIT" = "yes" ]; then
 fi
 
 verbose_p         && \
+makedistname      && \
 removedist     no && \
 createdist        && \
 clean             && \