ログ日記

作業ログと日記とメモ

GWTのHudson用ビルドスクリプト

GWT + Git + Hudson の設定 - より良い環境を求めて の続き


ほとんど変更がないけれども

#!/bin/bash

USAGE="Usage: gwt-build.sh com.company.appname.ModuleName dirName appPath"
if [ "$1" == "" ]; then
    echo "ERROR: Required module name."
    echo $USAGE
    exit 1
fi

if [ "$2" == "" ]; then
    echo "ERROR: Required dir name to deploy."
    echo $USAGE
    exit 1
fi

if [ "$3" == "" ]; then
    echo "ERROR: Required application path."
    echo $USAGE
    exit 1
fi

echo "setup..."
# copy libs and other files
GWT_HOME=/usr/local/gwt-2.1.0
SHARED_LIB=lib
rm -rf war/WEB-INF/lib; mkdir -p war/WEB-INF/lib
cp $GWT_HOME/gwt-servlet.jar war/WEB-INF/lib/
cp $SHARED_LIB/*.jar war/WEB-INF/lib/
rm -rf war/WEB-INF/classes; mkdir -p war/WEB-INF/classes
cd src
find . ! -name "*.java" -type f | cpio -pd ../war/WEB-INF/classes > /dev/null 2>&1
cd ..
echo product > war/WEB-INF/classes/env.txt
rm -f war/WEB-INF/classes/log4j.properties

echo "compile java..."
# compile java
CLASSPATH=$GWT_HOME/gwt-user.jar:$GWT_HOME/gwt-dev.jar
for jar in `ls $SHARED_LIB`; do
  CLASSPATH=$CLASSPATH:$SHARED_LIB/$jar
done
find src -name "*.java" | xargs javac -sourcepath src -d war/WEB-INF/classes -g:lines.vars.source -cp $CLASSPATH
RET=$?
if [ $RET -ne 0 ]; then
        exit $RET
fi

echo "compile gwt..."
# compile gwt
java -cp src:war/WEB-INF/classes:$CLASSPATH com.google.gwt.dev.Compiler -war war $1
RET=$?
if [ $RET -ne 0 ]; then
        exit $RET
fi


# upload and reload app
rsync -avz --delete war/ user@webapp_host:~$2
wget -O /dev/null --http-user=user --http-passwd=pass \
  "http://webapp_host:8080/manager/html/reload?path=$3"

リポジトリにlib/*.jar を含めた場合。
あとMVPのテストをしたらGWTコンパイルでエラーが出たのでクラスパスにWEB-INF/classesを含めた。