- adding the BSD license

- changed a buch of issues with cli builds and windows operations
- added the ability to persist init parameters in an gridworks.ini file (both used in windows and unix)


git-svn-id: http://google-refine.googlecode.com/svn/trunk@359 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Stefano Mazzocchi 2010-03-30 21:24:04 +00:00
parent f0fec31d98
commit 8508fbbd01
5 changed files with 220 additions and 112 deletions

View File

@ -1,5 +1,31 @@
/* /*
* (c) Copyright 2010 Metaweb Technologies, Inc. All rights reserved. * Copyright (c) 2010, Metaweb Technologies, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY METAWEB TECHNOLOGIES AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL METAWEB
* TECHNOLOGIES OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/ */
/* /*

View File

@ -10,10 +10,11 @@
| NOTE: this script expects the 'build.dir' and 'dist.dir' properties to be set | NOTE: this script expects the 'build.dir' and 'dist.dir' properties to be set
| when invoking it. This is done like this | when invoking it. This is done like this
| |
| ant -f build.xml -Dbuild.dir="/path/to/build/dir" -Ddist.dir="/path/to/dist/dir" | ant -f build.xml -Dbuild.dir="/path/to/build/dir" -Ddist.dir="/path/to/dist/dir" -Drevision="r3934"
| |
| the 'gridworks' shell script does this and it's meant to be the way to invoke ant, | Basically, this build file is designed to be invoked by the 'gridworks' shell
| so running this script directly in ant is not suggested. | script (this makes it easy to integrate into nightly-build and continuous
| integration systems).
+--> +-->
<project name="gridworks" default="build" basedir="."> <project name="gridworks" default="build" basedir=".">
@ -30,7 +31,8 @@
<property name="tests_classes.dir" value="${tests.dir}/classes" /> <property name="tests_classes.dir" value="${tests.dir}/classes" />
<property name="bundle.dir" value="${build.dir}/bundle" /> <property name="bundle.dir" value="${build.dir}/bundle" />
<property name="exe.dir" value="${build.dir}/exe" /> <property name="exe.dir" value="${build.dir}/exe" />
<property name="cli.dir" value="${build.dir}/cli" /> <property name="cli.name" value="gridworks-${version}" />
<property name="cli.dir" value="${build.dir}/cli/${cli.name}" />
<path id="class.path"> <path id="class.path">
<fileset dir="${lib.dir}"> <fileset dir="${lib.dir}">
@ -109,7 +111,7 @@
<config <config
headerType="console" headerType="console"
outfile="${exe.dir}/Gridworks.exe" outfile="${exe.dir}/Gridworks.exe"
jarPath="lib/gridworks-${version}.jar" jarPath="lib/gridworks-${version}-${revision}.jar"
dontWrapJar="true" dontWrapJar="true"
icon="${graphics.dir}/icon/gridworks.ico"> icon="${graphics.dir}/icon/gridworks.ico">
<classPath mainClass="com.metaweb.gridworks.Gridworks"> <classPath mainClass="com.metaweb.gridworks.Gridworks">
@ -142,13 +144,13 @@
<include name="*.dll"/> <include name="*.dll"/>
</fileset> </fileset>
</copy> </copy>
<copy file="${build.dir}/gridworks.jar" tofile="${exe.dir}/lib/gridworks-${version}.jar"/> <copy file="${build.dir}/gridworks.jar" tofile="${exe.dir}/lib/gridworks-${version}-${revision}.jar"/>
<copy todir="${exe.dir}/webapp"> <copy todir="${exe.dir}/webapp">
<fileset dir="${basedir}/src/main/webapp"> <fileset dir="${basedir}/src/main/webapp">
<include name="**/*"/> <include name="**/*"/>
</fileset> </fileset>
</copy> </copy>
<zip destfile="${dist.dir}/gridworks-${version}.zip" basedir="${exe.dir}"/> <zip destfile="${dist.dir}/gridworks-${version}-${revision}.zip" basedir="${exe.dir}"/>
</target> </target>
<target name="cli" depends="jar"> <target name="cli" depends="jar">
@ -165,33 +167,41 @@
</fileset> </fileset>
</copy> </copy>
<copy todir="${cli.dir}/build/classes"> <copy file="${build.dir}/gridworks.jar" tofile="${cli.dir}/lib/gridworks-${version}-${revision}.jar"/>
<fileset dir="${build.dir}/classes">
<include name="**"/>
</fileset>
</copy>
<copy todir="${cli.dir}/src/main/webapp"> <copy todir="${cli.dir}/src/main/webapp">
<fileset dir="${basedir}/src/main/webapp"> <fileset dir="${basedir}/src/main/webapp">
<include name="**/*"/> <include name="**/*"/>
</fileset> </fileset>
</copy> </copy>
<copy todir="${cli.dir}/thirdparty">
<fileset dir="${basedir}/thirdparty">
<include name="**/*"/>
</fileset>
</copy>
<copy todir="${cli.dir}/licenses"> <copy todir="${cli.dir}/licenses">
<fileset dir="${basedir}/licenses"> <fileset dir="${basedir}/licenses">
<include name="**/*"/> <include name="**/*"/>
</fileset> </fileset>
</copy> </copy>
<copy file="${basedir}/gridworks" tofile="${cli.dir}/gridworks"/> <copy file="${basedir}/gridworks.ini" tofile="${cli.dir}/gridworks.ini"/>
<copy file="${basedir}/gridworks.bat" tofile="${cli.dir}/gridworks.bat"/> <copy file="${basedir}/gridworks.bat" tofile="${cli.dir}/gridworks.bat"/>
<copy file="${basedir}/build.xml" tofile="${cli.dir}/build.xml"/>
<copy file="${basedir}/LICENSE.txt" tofile="${cli.dir}/LICENSE.txt"/> <copy file="${basedir}/LICENSE.txt" tofile="${cli.dir}/LICENSE.txt"/>
<copy file="${basedir}/README.txt" tofile="${cli.dir}/README.txt"/> <copy file="${basedir}/README.txt" tofile="${cli.dir}/README.txt"/>
<zip destfile="${dist.dir}/gridworks-${version}-cli.zip" basedir="${cli.dir}"/> <delete file="${cli.dir}/gridworks"/>
<zip destfile="${dist.dir}/gridworks-${version}-${revision}-cli.zip" basedir="${cli.dir}"/>
<delete file="${cli.dir}/gridworks.bat"/>
<delete dir="${cli.dir}/lib/native/windows"/>
<copy file="${basedir}/gridworks" tofile="${cli.dir}/gridworks"/>
<tar longfile="gnu" compression="gzip" destfile="${dist.dir}/gridworks-${version}-${revision}.tar.gz">
<tarfileset dir="${cli.dir}/.." filemode="755">
<include name="${cli.name}/gridworks"/>
</tarfileset>
<tarfileset dir="${cli.dir}/..">
<include name="${cli.name}/**"/>
<exclude name="${cli.name}/gridworks"/>
</tarfileset>
</tar>
</target> </target>
<target name="clean"> <target name="clean">

112
gridworks
View File

@ -4,6 +4,8 @@
# Gridworks Control System # # Gridworks Control System #
########################################################## ##########################################################
# -------------- functions ------------------------------------
fail () { fail () {
cat <<EOF cat <<EOF
ERROR: $1 ERROR: $1
@ -36,9 +38,12 @@ where [options] include:
-d <path> path to the data directory -d <path> path to the data directory
default: OS dependent default: OS dependent
-m <memory> max memory heap size to use
default: 1024M
--debug enable JVM debugging (on port 8000) --debug enable JVM debugging (on port 8000)
--jmx enable JMX monitoring (for jconsole) --jmx enable JMX monitoring (for jconsole and jvisualvm)
and <action> is one of and <action> is one of
@ -49,8 +54,9 @@ and <action> is one of
make_dmg <version> ........ Make MacOSX DMG distribution make_dmg <version> ........ Make MacOSX DMG distribution
make_exe <version> ........ Make Windows EXE distribution make_exe <version> ........ Make Windows EXE distribution
make_cli <version> ........ Make zip distribution to be run at command line make_cli <version> ........ Make distributions to be run at command line
make_all <version> ........ Make all distributions
dist <version> ............ Make all distributions
clean ..................... Clean compiled classes clean ..................... Clean compiled classes
distclean ................. Remove all generated files distclean ................. Remove all generated files
@ -63,18 +69,11 @@ add_option() {
OPTS="$OPTS $1" OPTS="$OPTS $1"
} }
OPTS="$GRIDWORKS_OPTS" load_configs() {
cat $1 | egrep "^[A-Z]" | sed 's/^\(.*\)$/export \1/' > .$1
# Normalize the current directory . ./.$1
cd `dirname $0` rm ./.$1
}
SYSTEM=`uname`
if [ "$SYSTEM" == "Darwin" ] && [ "$JAVA_HOME" == "" ] ; then
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home"
fi
# ----- actions -------------------------------------------------
check_macosx() { check_macosx() {
if [ "$SYSTEM" != 'Darwin' ] ; then if [ "$SYSTEM" != 'Darwin' ] ; then
@ -102,8 +101,7 @@ ant_prepare() {
ant() { ant() {
ant_prepare ant_prepare
echo $NUM_VERSION $ANT -f build.xml -Dbuild.dir="$GRIDWORKS_BUILD_DIR" -Ddist.dir="$GRIDWORKS_DIST_DIR" -Dversion="$VERSION" -Dnum_version="$NUM_VERSION" -Drevision="$REVISION" $1 || exit 1
$ANT -f build.xml -Dbuild.dir="$GRIDWORKS_BUILD_DIR" -Ddist.dir="$GRIDWORKS_DIST_DIR" -Dversion="$VERSION" -Dnum_version="$NUM_VERSION" -Djava.options="$JAVA_OPTIONS" $1 || exit 1
} }
dist_prepare() { dist_prepare() {
@ -122,23 +120,6 @@ launch4j_prepare() {
cd .. cd ..
} }
protobuf_prepare() {
cd thirdparty
PROTOBUF_TAR=`ls | grep protobuf | grep tar.gz | grep -v svn`
PROTOBUF_DIR=`echo $PROTOBUF_TAR | sed 's/.tar.gz//'`
PROTOC="`pwd`/$PROTOBUF_DIR/bin/protoc"
if [ ! -f $PROTOC ] ; then
tar xzf $PROTOBUF_TAR -C . || exit 1
cd $PROTOBUF_DIR
./configure --prefix=`pwd`
make
make install
cd ..
fi
PROTOC="`pwd`/$PROTOBUF_DIR/bin/protoc"
cd ..
}
get_version() { get_version() {
VERSION=$1 VERSION=$1
@ -149,7 +130,19 @@ get_version() {
NUM_VERSION=`echo $VERSION | sed 's/[a-zA-Z]//g'` NUM_VERSION=`echo $VERSION | sed 's/[a-zA-Z]//g'`
} }
make_all() { get_revision() {
if [ -d ".svn" ]; then
INFO=`svn info`
elif [ -d ".git" ]; then
INFO=`git svn info`
else
error "cannot obtain revision, exiting!"
fi
REVISION=`echo $INFO | sed 's/.*Revision: /r/' | sed 's/ .*//'`
}
dist() {
make_dmg $1 make_dmg $1
make_exe $1 make_exe $1
make_cli $1 make_cli $1
@ -160,23 +153,30 @@ make_exe() {
dist_prepare dist_prepare
launch4j_prepare launch4j_prepare
get_version $1 get_version $1
get_revision
ant exe ant exe
echo ""
echo "Built exe ZIP for version $VERSION-$REVISION"
} }
make_cli() { make_cli() {
check_macosx
dist_prepare dist_prepare
launch4j_prepare
get_version $1 get_version $1
get_revision
ant cli ant cli
echo ""
echo "Built cli ZIP for version $VERSION-$REVISION"
} }
make_dmg() { make_dmg() {
check_macosx check_macosx
dist_prepare dist_prepare
get_version $1 get_version $1
get_revision
ant bundle ant bundle
@ -220,8 +220,11 @@ make_dmg() {
sync sync
hdiutil detach $DEVICE hdiutil detach $DEVICE
hdiutil convert "$GRIDWORKS_BUILD_DIR/temp_gridworks.dmg" -format UDZO -imagekey zlib-level=9 -o "$GRIDWORKS_DIST_DIR/gridworks-$VERSION.dmg" hdiutil convert "$GRIDWORKS_BUILD_DIR/temp_gridworks.dmg" -format UDZO -imagekey zlib-level=9 -o "$GRIDWORKS_DIST_DIR/gridworks-$VERSION.dmg"
hdiutil internet-enable -yes "$GRIDWORKS_DIST_DIR/gridworks-$VERSION.dmg" hdiutil internet-enable -yes "$GRIDWORKS_DIST_DIR/gridworks-$VERSION-$REVISION.dmg"
rm -f "$GRIDWORKS_BUILD_DIR/temp_gridworks.dmg" rm -f "$GRIDWORKS_BUILD_DIR/temp_gridworks.dmg"
echo ""
echo "Built DMG for version $VERSION-$REVISION"
} }
test() { test() {
@ -250,9 +253,11 @@ test() {
run() { run() {
if [ ! -d $GRIDWORKS_BUILD_DIR/classes ] ; then if [ ! -d $GRIDWORKS_BUILD_DIR/classes ] ; then
if [ `ls $GRIDWORKS_LIB_DIR | grep gridworks` == "" ] ; then
ant build ant build
echo "" echo ""
fi fi
fi
if [ "$SYSTEM" == 'Darwin' ] ; then if [ "$SYSTEM" == 'Darwin' ] ; then
OPTS="-Xdock:name=Gridworks -Xdock:icon=src/graphics/icon/gridworks.icns $OPTS" OPTS="-Xdock:name=Gridworks -Xdock:icon=src/graphics/icon/gridworks.icns $OPTS"
@ -290,6 +295,8 @@ execute() {
exec $RUN_CMD $* exec $RUN_CMD $*
} }
# -------------------------- script -----------------------------
# ----- We called without arguments print the usage ------------- # ----- We called without arguments print the usage -------------
[ $# -gt 0 ] || usage [ $# -gt 0 ] || usage
@ -298,7 +305,21 @@ execute() {
cd `dirname $0` cd `dirname $0`
# ----- Make sure there is a java environment installed ------------------------- # ----- Default values ------------------------------------------
OPTS=""
SYSTEM=`uname`
if [ "$SYSTEM" == "Darwin" ] && [ "$JAVA_HOME" == "" ] ; then
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home"
fi
# ----- Load configurations -------------------------------------
load_configs gridworks.ini
# ----- Make sure there is an appropriate java environment is available -------------
if [ ! -z "$JAVA_HOME" ] ; then if [ ! -z "$JAVA_HOME" ] ; then
JAVA="$JAVA_HOME/bin/java" JAVA="$JAVA_HOME/bin/java"
@ -327,6 +348,7 @@ while [ $# -ne 0 ] ; do
-i) shift; GRIDWORKS_HOST="$1"; shift; continue;; -i) shift; GRIDWORKS_HOST="$1"; shift; continue;;
-w) shift; GRIDWORKS_WEBAPP="$1"; shift; continue;; -w) shift; GRIDWORKS_WEBAPP="$1"; shift; continue;;
-d) shift; GRIDWORKS_DATA_DIR="$1"; shift; continue;; -d) shift; GRIDWORKS_DATA_DIR="$1"; shift; continue;;
-m) shift; GRIDWORKS_MEMORY="$1"; shift; continue;;
--debug) shift; add_option '-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n'; continue;; --debug) shift; add_option '-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n'; continue;;
--jmx) shift; add_option '-Dcom.sun.management.jmxremote'; continue;; --jmx) shift; add_option '-Dcom.sun.management.jmxremote'; continue;;
-*) fail "Invalid option: $1";; -*) fail "Invalid option: $1";;
@ -339,10 +361,15 @@ ACTION=$1; shift
# ----- Verify and Set Required Environment Variables ------------------------- # ----- Verify and Set Required Environment Variables -------------------------
if [ "$JAVA_OPTIONS" == "" ] ; then if [ "$JAVA_OPTIONS" == "" ] ; then
JAVA_OPTIONS="-Xms256M -Xmx1024M -XX:+UseParallelGC" JAVA_OPTIONS=""
fi fi
add_option "$JAVA_OPTIONS" add_option "$JAVA_OPTIONS"
if [ "$GRIDWORKS_MEMORY" == "" ] ; then
GRIDWORKS_MEMORY="1024M"
fi
add_option "-Xms256M -Xmx$GRIDWORKS_MEMORY"
if [ "$GRIDWORKS_PORT" == "" ] ; then if [ "$GRIDWORKS_PORT" == "" ] ; then
GRIDWORKS_PORT="3333" GRIDWORKS_PORT="3333"
fi fi
@ -408,9 +435,10 @@ case "$ACTION" in
make_cli) make_cli)
make_cli $1;; make_cli $1;;
make_all) dist)
make_all $1;; dist $1;;
*) *)
usage; ;; usage; ;;
esac esac

View File

@ -33,6 +33,9 @@ echo default src\main\webapp
echo. echo.
echo /d enable JVM debugging (on port 8000) echo /d enable JVM debugging (on port 8000)
echo. echo.
echo /m <memory> max memory heap size to use
echo default: 1024M
echo.
echo /x enable JMX monitoring (for jconsole and friends) echo /x enable JMX monitoring (for jconsole and friends)
echo. echo.
echo and <action> is one of echo and <action> is one of
@ -53,10 +56,22 @@ goto end
if not "%JAVA_HOME%" == "" goto gotJavaHome if not "%JAVA_HOME%" == "" goto gotJavaHome
echo You must set JAVA_HOME to point at your Java Development Kit installation echo You must set JAVA_HOME to point at your Java Development Kit installation
echo.
echo If you don't know how to do this, follow the instructions at
echo.
echo http://bit.ly/1c2gkR
echo.
goto fail goto fail
:gotJavaHome :gotJavaHome
set OPTS=%GRIDWORKS_OPTS% rem --- Read ini file --------------------------------------------
set OPTS=
for /f "tokens=1,2 delims==" %%a in (gridworks.ini) do (
set %%a=%%b
)
rem --- Argument parsing -------------------------------------------- rem --- Argument parsing --------------------------------------------
@ -67,6 +82,7 @@ if ""%1"" == ""/p"" goto arg-p
if ""%1"" == ""/i"" goto arg-i if ""%1"" == ""/i"" goto arg-i
if ""%1"" == ""/w"" goto arg-w if ""%1"" == ""/w"" goto arg-w
if ""%1"" == ""/d"" goto arg-d if ""%1"" == ""/d"" goto arg-d
if ""%1"" == ""/m"" goto arg-m
if ""%1"" == ""/x"" goto arg-x if ""%1"" == ""/x"" goto arg-x
goto endArgumentParsing goto endArgumentParsing
@ -82,6 +98,10 @@ goto shift2loop
set GRIDWORKS_WEBAPP=%2 set GRIDWORKS_WEBAPP=%2
goto shift2loop goto shift2loop
:arg-m
set GRIDWORKS_MEMORY=%2
goto shift2loop
:arg-d :arg-d
set OPTS=%OPTS% -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n set OPTS=%OPTS% -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
goto shift2loop goto shift2loop
@ -100,10 +120,15 @@ goto loop
rem --- Fold in Environment Vars -------------------------------------------- rem --- Fold in Environment Vars --------------------------------------------
if not "%JAVA_OPTIONS%" == "" goto gotJavaOptions if not "%JAVA_OPTIONS%" == "" goto gotJavaOptions
set JAVA_OPTIONS=-Xms256M -Xmx1024M -XX:+UseLargePages -XX:+UseParallelGC set JAVA_OPTIONS=
:gotJavaOptions :gotJavaOptions
set OPTS=%OPTS% %JAVA_OPTIONS% set OPTS=%OPTS% %JAVA_OPTIONS%
if not "%GRIDWORKS_MEMORY%" == "" goto gotMemory
set GRIDWORKS_MEMORY=1024M
:gotMemory
set OPTS=%OPTS% -Xms256M -Xmx%GRIDWORKS_MEMORY%
if not "%GRIDWORKS_PORT%" == "" goto gotPort if not "%GRIDWORKS_PORT%" == "" goto gotPort
set GRIDWORKS_PORT=3333 set GRIDWORKS_PORT=3333
:gotPort :gotPort
@ -140,11 +165,24 @@ goto usage
:doRun :doRun
set CLASSPATH="%GRIDWORKS_BUILD_DIR%\classes;%GRIDWORKS_LIB_DIR%\*" set CLASSPATH="%GRIDWORKS_BUILD_DIR%\classes;%GRIDWORKS_LIB_DIR%\*"
echo %OPTS%
"%JAVA_HOME%\bin\java.exe" -cp %CLASSPATH% %OPTS% -Djava.library.path=lib/native/windows com.metaweb.gridworks.Gridworks "%JAVA_HOME%\bin\java.exe" -cp %CLASSPATH% %OPTS% -Djava.library.path=lib/native/windows com.metaweb.gridworks.Gridworks
goto end goto end
:doAnt :doAnt
ant -f build.xml -Dbuild.dir="%GRIDWORKS_BUILD_DIR%" -Ddist.dir="%GRIDWORKS_DIST_DIR%" -Dversion="%VERSION%" %ACTION% if not "%ANT_HOME%" == "" goto gotAntHome
echo You must have Apache Ant installed and the ANT_HOME environment variable to point to it
echo.
echo You can find a copy of ant in the "\thirdparty" folder or download it from
echo.
echo http://ant.apache.org/
echo.
echo If you don't know how to set environment variables, follow the instructions at
echo.
echo http://bit.ly/1c2gkR
echo.
:gotAntHome
"%ANT_HOME%\bin\ant.bat" -f build.xml -Dbuild.dir="%GRIDWORKS_BUILD_DIR%" %ACTION%
goto end goto end
:end :end

6
gridworks.ini Normal file
View File

@ -0,0 +1,6 @@
#GRIDWORKS_PORT=3333
#GRIDWORKS_HOST=127.0.0.1
#GRIDWORKS_MEMORY=1024M
#JAVA_HOME=""
#JAVA_OPTIONS="-XX:+UseParallelGC -XX:+UseLargePages"