- 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.
*
*/
/*

118
build.xml
View File

@ -10,10 +10,11 @@
| NOTE: this script expects the 'build.dir' and 'dist.dir' properties to be set
| 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,
| so running this script directly in ant is not suggested.
| Basically, this build file is designed to be invoked by the 'gridworks' shell
| script (this makes it easy to integrate into nightly-build and continuous
| integration systems).
+-->
<project name="gridworks" default="build" basedir=".">
@ -30,7 +31,8 @@
<property name="tests_classes.dir" value="${tests.dir}/classes" />
<property name="bundle.dir" value="${build.dir}/bundle" />
<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">
<fileset dir="${lib.dir}">
@ -100,16 +102,16 @@
<target name="exe" depends="jar">
<mkdir dir="${exe.dir}"/>
<taskdef
name="launch4j"
classname="net.sf.launch4j.ant.Launch4jTask"
classpath="${tools.dir}/launch4j/launch4j.jar:${tools.dir}/launch4j/lib/xstream.jar"
/>
<taskdef
name="launch4j"
classname="net.sf.launch4j.ant.Launch4jTask"
classpath="${tools.dir}/launch4j/launch4j.jar:${tools.dir}/launch4j/lib/xstream.jar"
/>
<launch4j>
<config
headerType="console"
outfile="${exe.dir}/Gridworks.exe"
jarPath="lib/gridworks-${version}.jar"
jarPath="lib/gridworks-${version}-${revision}.jar"
dontWrapJar="true"
icon="${graphics.dir}/icon/gridworks.ico">
<classPath mainClass="com.metaweb.gridworks.Gridworks">
@ -142,58 +144,66 @@
<include name="*.dll"/>
</fileset>
</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">
<fileset dir="${basedir}/src/main/webapp">
<include name="**/*"/>
</fileset>
</copy>
<zip destfile="${dist.dir}/gridworks-${version}.zip" basedir="${exe.dir}"/>
</target>
<target name="cli" depends="jar">
<mkdir dir="${cli.dir}"/>
<zip destfile="${dist.dir}/gridworks-${version}-${revision}.zip" basedir="${exe.dir}"/>
</target>
<target name="cli" depends="jar">
<mkdir dir="${cli.dir}"/>
<copy todir="${cli.dir}/lib">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</copy>
<copy todir="${cli.dir}/lib/native/windows">
<fileset dir="${lib.dir}/native/windows">
<include name="*.dll"/>
</fileset>
</copy>
<copy todir="${cli.dir}/lib">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</copy>
<copy todir="${cli.dir}/lib/native/windows">
<fileset dir="${lib.dir}/native/windows">
<include name="*.dll"/>
</fileset>
</copy>
<copy file="${build.dir}/gridworks.jar" tofile="${cli.dir}/lib/gridworks-${version}-${revision}.jar"/>
<copy todir="${cli.dir}/src/main/webapp">
<fileset dir="${basedir}/src/main/webapp">
<include name="**/*"/>
</fileset>
</copy>
<copy todir="${cli.dir}/licenses">
<fileset dir="${basedir}/licenses">
<include name="**/*"/>
</fileset>
</copy>
<copy file="${basedir}/gridworks.ini" tofile="${cli.dir}/gridworks.ini"/>
<copy file="${basedir}/gridworks.bat" tofile="${cli.dir}/gridworks.bat"/>
<copy file="${basedir}/LICENSE.txt" tofile="${cli.dir}/LICENSE.txt"/>
<copy file="${basedir}/README.txt" tofile="${cli.dir}/README.txt"/>
<copy todir="${cli.dir}/build/classes">
<fileset dir="${build.dir}/classes">
<include name="**"/>
</fileset>
</copy>
<copy todir="${cli.dir}/src/main/webapp">
<fileset dir="${basedir}/src/main/webapp">
<include name="**/*"/>
</fileset>
</copy>
<copy todir="${cli.dir}/thirdparty">
<fileset dir="${basedir}/thirdparty">
<include name="**/*"/>
</fileset>
</copy>
<copy todir="${cli.dir}/licenses">
<fileset dir="${basedir}/licenses">
<include name="**/*"/>
</fileset>
</copy>
<copy file="${basedir}/gridworks" tofile="${cli.dir}/gridworks"/>
<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}/README.txt" tofile="${cli.dir}/README.txt"/>
<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>
<zip destfile="${dist.dir}/gridworks-${version}-cli.zip" basedir="${cli.dir}"/>
</target>
<target name="clean">
<delete file="${build.dir}/gridworks.jar" />
<delete dir="${classes.dir}" />

122
gridworks
View File

@ -4,6 +4,8 @@
# Gridworks Control System #
##########################################################
# -------------- functions ------------------------------------
fail () {
cat <<EOF
ERROR: $1
@ -35,10 +37,13 @@ where [options] include:
-d <path> path to the data directory
default: OS dependent
-m <memory> max memory heap size to use
default: 1024M
--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
@ -49,8 +54,9 @@ and <action> is one of
make_dmg <version> ........ Make MacOSX DMG distribution
make_exe <version> ........ Make Windows EXE distribution
make_cli <version> ........ Make zip distribution to be run at command line
make_all <version> ........ Make all distributions
make_cli <version> ........ Make distributions to be run at command line
dist <version> ............ Make all distributions
clean ..................... Clean compiled classes
distclean ................. Remove all generated files
@ -58,24 +64,17 @@ and <action> is one of
EOF
exit 1
}
add_option() {
OPTS="$OPTS $1"
}
OPTS="$GRIDWORKS_OPTS"
# Normalize the current directory
cd `dirname $0`
SYSTEM=`uname`
if [ "$SYSTEM" == "Darwin" ] && [ "$JAVA_HOME" == "" ] ; then
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home"
fi
# ----- actions -------------------------------------------------
load_configs() {
cat $1 | egrep "^[A-Z]" | sed 's/^\(.*\)$/export \1/' > .$1
. ./.$1
rm ./.$1
}
check_macosx() {
if [ "$SYSTEM" != 'Darwin' ] ; then
error "This action can only run on MacOSX"
@ -102,8 +101,7 @@ ant_prepare() {
ant() {
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" -Djava.options="$JAVA_OPTIONS" $1 || exit 1
$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
}
dist_prepare() {
@ -122,23 +120,6 @@ launch4j_prepare() {
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() {
VERSION=$1
@ -149,7 +130,19 @@ get_version() {
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_exe $1
make_cli $1
@ -160,23 +153,30 @@ make_exe() {
dist_prepare
launch4j_prepare
get_version $1
get_revision
ant exe
echo ""
echo "Built exe ZIP for version $VERSION-$REVISION"
}
make_cli() {
check_macosx
dist_prepare
launch4j_prepare
get_version $1
get_revision
ant cli
echo ""
echo "Built cli ZIP for version $VERSION-$REVISION"
}
make_dmg() {
check_macosx
dist_prepare
get_version $1
get_revision
ant bundle
@ -220,8 +220,11 @@ make_dmg() {
sync
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 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"
echo ""
echo "Built DMG for version $VERSION-$REVISION"
}
test() {
@ -250,8 +253,10 @@ test() {
run() {
if [ ! -d $GRIDWORKS_BUILD_DIR/classes ] ; then
ant build
echo ""
if [ `ls $GRIDWORKS_LIB_DIR | grep gridworks` == "" ] ; then
ant build
echo ""
fi
fi
if [ "$SYSTEM" == 'Darwin' ] ; then
@ -290,6 +295,8 @@ execute() {
exec $RUN_CMD $*
}
# -------------------------- script -----------------------------
# ----- We called without arguments print the usage -------------
[ $# -gt 0 ] || usage
@ -298,7 +305,21 @@ execute() {
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
JAVA="$JAVA_HOME/bin/java"
@ -327,6 +348,7 @@ while [ $# -ne 0 ] ; do
-i) shift; GRIDWORKS_HOST="$1"; shift; continue;;
-w) shift; GRIDWORKS_WEBAPP="$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;;
--jmx) shift; add_option '-Dcom.sun.management.jmxremote'; continue;;
-*) fail "Invalid option: $1";;
@ -339,10 +361,15 @@ ACTION=$1; shift
# ----- Verify and Set Required Environment Variables -------------------------
if [ "$JAVA_OPTIONS" == "" ] ; then
JAVA_OPTIONS="-Xms256M -Xmx1024M -XX:+UseParallelGC"
JAVA_OPTIONS=""
fi
add_option "$JAVA_OPTIONS"
if [ "$GRIDWORKS_MEMORY" == "" ] ; then
GRIDWORKS_MEMORY="1024M"
fi
add_option "-Xms256M -Xmx$GRIDWORKS_MEMORY"
if [ "$GRIDWORKS_PORT" == "" ] ; then
GRIDWORKS_PORT="3333"
fi
@ -408,9 +435,10 @@ case "$ACTION" in
make_cli)
make_cli $1;;
make_all)
make_all $1;;
dist)
dist $1;;
*)
usage; ;;
esac

View File

@ -7,7 +7,7 @@ rem Home of Java installation.
rem
rem JAVA_OPTIONS
rem Extra options to pass to the JVM
rem
rem
if "%OS%"=="Windows_NT" @setlocal
if "%OS%"=="WINNT" @setlocal
@ -31,7 +31,10 @@ echo.
echo /w <path> path to the webapp
echo default src\main\webapp
echo.
echo /d enable JVM debugging (on port 8000)
echo /d enable JVM debugging (on port 8000)
echo.
echo /m <memory> max memory heap size to use
echo default: 1024M
echo.
echo /x enable JMX monitoring (for jconsole and friends)
echo.
@ -39,7 +42,7 @@ echo and <action> is one of
echo.
echo build ..................... Build Gridworks
echo run ....................... Run Gridworks
echo.
echo.
echo clean ..................... Clean compiled classes
echo distclean ................. Remove all generated files
echo.
@ -52,11 +55,23 @@ goto end
:endUtils
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
: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 --------------------------------------------
@ -67,6 +82,7 @@ if ""%1"" == ""/p"" goto arg-p
if ""%1"" == ""/i"" goto arg-i
if ""%1"" == ""/w"" goto arg-w
if ""%1"" == ""/d"" goto arg-d
if ""%1"" == ""/m"" goto arg-m
if ""%1"" == ""/x"" goto arg-x
goto endArgumentParsing
@ -81,6 +97,10 @@ goto shift2loop
:arg-w
set GRIDWORKS_WEBAPP=%2
goto shift2loop
:arg-m
set GRIDWORKS_MEMORY=%2
goto shift2loop
:arg-d
set OPTS=%OPTS% -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
@ -100,9 +120,14 @@ goto loop
rem --- Fold in Environment Vars --------------------------------------------
if not "%JAVA_OPTIONS%" == "" goto gotJavaOptions
set JAVA_OPTIONS=-Xms256M -Xmx1024M -XX:+UseLargePages -XX:+UseParallelGC
set JAVA_OPTIONS=
:gotJavaOptions
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
set GRIDWORKS_PORT=3333
@ -139,12 +164,25 @@ if ""%ACTION%"" == ""run"" goto doRun
goto usage
: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
goto end
:doAnt
ant -f build.xml -Dbuild.dir="%GRIDWORKS_BUILD_DIR%" -Ddist.dir="%GRIDWORKS_DIST_DIR%" -Dversion="%VERSION%" %ACTION%
:doAnt
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
: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"