2009-11-08 05:12:12 +08:00
#!/bin/bash
2011-02-18 09:58:15 +08:00
set -e
2011-04-09 23:48:36 +08:00
set -u
2011-02-18 09:58:15 +08:00
2011-04-09 23:48:36 +08:00
WISE_VERSION = $1
2009-11-08 05:12:12 +08:00
BASE_DIR = ` pwd `
TARGET_DIR = $BASE_DIR /target
JETTY_DIR = $TARGET_DIR /wisemapping-$WISE_VERSION
WISE_WEBAPP_DIR = $JETTY_DIR /webapps/wisemapping
2013-02-01 01:49:04 +08:00
JETTY_VERSION = 8.1.8.v20121106
2012-09-30 04:38:51 +08:00
JETTY_DIST_DIR = jetty-distribution-${ JETTY_VERSION }
2012-07-02 09:34:01 +08:00
JETTY_ZIP = ${ JETTY_DIST_DIR } .zip
2009-11-08 05:12:12 +08:00
# Clean ...
2011-07-05 23:31:17 +08:00
mvn -o -f $BASE_DIR /../pom.xml clean
2011-04-09 23:48:36 +08:00
[ ! -e target ] && mkdir target
2011-02-18 09:58:15 +08:00
rm -fr ${ JETTY_DIR }
2011-07-05 23:31:17 +08:00
rm -fr ${ TARGET_DIR } /${ JETTY_DIST_DIR }
2009-11-08 05:12:12 +08:00
# Prepare resources ..
2012-07-02 09:34:01 +08:00
mvn -o -f $BASE_DIR /../pom.xml package -Dmaven.test.skip= true
2009-11-08 05:12:12 +08:00
2011-02-18 09:58:15 +08:00
if [ ! -f ./target/${ JETTY_ZIP } ]
2009-11-08 05:12:12 +08:00
then
echo "Download Jetty"
2012-09-30 04:38:51 +08:00
wget http://download.eclipse.org/jetty/${ JETTY_VERSION } /dist/${ JETTY_ZIP } -P $TARGET_DIR
2009-11-08 05:12:12 +08:00
fi
echo "Unzip Jetty ...:"
2011-02-18 09:58:15 +08:00
unzip ${ TARGET_DIR } /${ JETTY_ZIP } -d ${ TARGET_DIR } / > /dev/null
mv ${ TARGET_DIR } /${ JETTY_DIST_DIR } ${ JETTY_DIR }
2012-07-02 09:34:01 +08:00
2009-11-08 05:12:12 +08:00
# Clean unsed files ...
2012-07-02 07:23:18 +08:00
rm -rf $JETTY_DIR /webapps/*
rm -rf $JETTY_DIR /contexts/*
2012-07-02 09:34:01 +08:00
rm -rf $JETTY_DIR /javadoc
2009-11-08 05:12:12 +08:00
# Now, start wise-webapps customization ...
echo "Unzip wisemappig.war ..."
mkdir $WISE_WEBAPP_DIR
unzip $BASE_DIR /../wise-webapp/target/wisemapping.war -d $WISE_WEBAPP_DIR >/dev/null
2012-07-02 09:34:01 +08:00
# DB Configuration ...
2012-11-04 12:06:02 +08:00
sed 's/\${database.base.url}\/db\/wisemapping/webapps\/wisemapping\/WEB-INF\/database\/wisemapping/' $WISE_WEBAPP_DIR /WEB-INF/app.properties > $WISE_WEBAPP_DIR /WEB-INF/app.properties2
2012-07-02 09:34:01 +08:00
mv $WISE_WEBAPP_DIR /WEB-INF/app.properties2 $WISE_WEBAPP_DIR /WEB-INF/app.properties
2009-11-08 05:12:12 +08:00
mkdir $WISE_WEBAPP_DIR /WEB-INF/database
2009-11-08 05:32:33 +08:00
cp -r $BASE_DIR /../wise-webapp/target/db/* $WISE_WEBAPP_DIR /WEB-INF/database/
2009-11-08 05:12:12 +08:00
cp $BASE_DIR /wisemapping.xml $JETTY_DIR /contexts/
2011-04-09 23:48:36 +08:00
# Distribute scripts
2013-03-29 04:06:34 +08:00
cp -r $BASE_DIR /../config/ $TARGET_DIR /wisemapping-$WISE_VERSION /config
2012-11-05 05:23:48 +08:00
cp ./start.sh ${ JETTY_DIR } /
2011-04-09 23:48:36 +08:00
2012-07-13 12:08:12 +08:00
# Store version
2012-07-14 08:15:12 +08:00
echo $1 > $WISE_WEBAPP_DIR /version
git rev-parse HEAD >> $WISE_WEBAPP_DIR /version
2012-07-13 12:08:12 +08:00
2011-04-09 23:48:36 +08:00
# Zip all ...
2009-11-08 05:12:12 +08:00
cd $TARGET_DIR
zip -r wisemapping-$WISE_VERSION .zip wisemapping-$WISE_VERSION
cd ..