forked from h2oai/h2o-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·187 lines (165 loc) · 5.46 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#! /bin/bash
# determine the correct separator of multiple paths
if [ `uname` = "Darwin" ]
then
UNAMECMD="uname"
else
UNAMECMD="uname -o"
fi
if [ `$UNAMECMD` = "Cygwin" ]
then
SEP=";"
else
SEP=":"
fi
# Setup script error handling
set -o errexit ## set -e : exit the script if any statement returns a non-true return value
# ------------------------------------------------------------------------------
# basic build properties
# ------------------------------------------------------------------------------
# This is where the source files (java) and resources are relative to the path of this file
SRC=src/main/java
TESTSRC=src/test/java
RESOURCES=src/main/resources
# and this is where the jar contents is stored relative to this file again
JAR_ROOT=lib
# additional dependencies, relative to this file, but all dependencies should be
# inside the JAR_ROOT tree so that they are packed to the jar file properly
DEPENDENCIES="${JAR_ROOT}/jama/*${SEP}${JAR_ROOT}/apache/*${SEP}${JAR_ROOT}/junit/*${SEP}${JAR_ROOT}/gson/*${SEP}${JAR_ROOT}/javassist.jar${SEP}${JAR_ROOT}/poi/*${SEP}${JAR_ROOT}/s3/*${SEP}${JAR_ROOT}/jets3t/*${SEP}${JAR_ROOT}/log4j/*${SEP}${JAR_ROOT}/mockito/*${SEP}${JAR_ROOT}/jogamp/*"
DEFAULT_HADOOP_VERSION="cdh3"
OUTDIR="target"
JAR_FILE="${OUTDIR}/h2o.jar"
SRC_JAR_FILE="${OUTDIR}/h2o-sources.jar"
JAVA=`which java`||echo 'Missing java, please install jdk'
JAVAC=`which javac`||echo 'Missing javac, please install jdk'
JAVADOC=`which javadoc`||echo 'Missing javadoc, please install jdk'
# need bootclasspath to point to jdk1.6 rt.jar bootstrap classes
# extdirs can also be passed as -extdirs
JAVAC_ARGS="-g
-source 1.6
-target 1.6
-XDignore.symbol.file
-Xlint:all
-Xlint:-deprecation
-Xlint:-serial
-Xlint:-rawtypes
-Xlint:-unchecked "
JAR=`which jar`
ZIP=`which zip`
GIT=`which git || which false`
CLASSES="${OUTDIR}/classes"
VERSION_PROPERTIES="${CLASSES}/version.properties"
# Clean up also /tmp content (/tmp/h2o-temp-*, /tmp/File*tmp)
# Note: /tmp is specific for Linux.
WIPE_TMP=true
# Calculate MYNAME based on platform.
if [ ! -z "$LOGNAME" ]; then
# Unix
MYNAME=`echo ${LOGNAME} | sed 's/ /_/g'`
else
if [ ! -z "$USERNAME" ]; then
# Windows
MYNAME=`echo ${USERNAME} | sed 's/ /_/g'`
else
MYNAME="UnknownLogin"
fi
fi
# Load user-specific properties if they are exist.
# The properties can override the settings above.
LOCAL_PROPERTIES_FILE="./build.local.conf"
[ -f "$LOCAL_PROPERTIES_FILE" ] && source "$LOCAL_PROPERTIES_FILE"
# ------------------------------------------------------------------------------
# script
# ------------------------------------------------------------------------------
function clean() {
echo "cleaning..."
rm -fr ${OUTDIR}
if [ "$WIPE_TMP" = "true" ]; then
echo " - wiping tmp..."
rm -fr /tmp/h2o-"${MYNAME}"/h2o-temp-*
fi
mkdir ${OUTDIR}
mkdir ${CLASSES}
rm -fr hadoop/target
}
function build_classes() {
echo "building classes..."
local CLASSPATH="${JAR_ROOT}${SEP}${DEPENDENCIES}${SEP}${JAR_ROOT}/hadoop/${DEFAULT_HADOOP_VERSION}/*"
"$JAVAC" ${JAVAC_ARGS} \
-cp "${CLASSPATH}" \
-sourcepath "$SRC" \
-d "$CLASSES" \
$SRC/water/*java \
$SRC/water/*/*java \
$SRC/jsr166y/*java \
$TESTSRC/*/*java \
$TESTSRC/*/*/*java
}
function build_initializer() {
echo "building initializer..."
local CLASSPATH="${JAR_ROOT}${SEP}${DEPENDENCIES}${SEP}${JAR_ROOT}/hadoop/${DEFAULT_HADOOP_VERSION}/*"
pushd lib
"$JAR" xf javassist.jar
rm -rf META-INF
popd
}
function build_jar() {
echo "creating jar file... ${JAR_FILE}"
# include all libraries
cd ${JAR_ROOT}
"$JAR" -cfm ../${JAR_FILE} ../manifest.txt `/usr/bin/find . -type f | grep -v 'sources.jar' | grep -v 'hadoop/mapr' | grep -v 'hadoop/hdp'`
cd ..
# include H2O classes
"$JAR" uf ${JAR_FILE} -C "${CLASSES}" .
# Pick up R jars
if [ -d r_pack_tmp ]; then
"$JAR" uf ${JAR_FILE} -C r_pack_tmp .
rm -fr r_pack_tmp
fi
"$ZIP" -qd ${JAR_FILE} javassist.jar
}
function build_src_jar() {
echo "creating src jar file... ${SRC_JAR_FILE}"
# include H2O source files
"$JAR" cf ${SRC_JAR_FILE} -C "${SRC}" .
"$JAR" uf ${SRC_JAR_FILE} -C "${TESTSRC}" .
}
function build_samples() {
echo "building samples..."
mkdir -p h2o-samples/target/classes
"$JAVAC" \
-cp ${JAR_FILE}${SEP}${DEPENDENCIES}${SEP}${JAR_ROOT}/hadoop/${DEFAULT_HADOOP_VERSION}/* \
-d h2o-samples/target/classes \
-sourcepath h2o-samples/src/main/java \
h2o-samples/src/main/java/*/*java
}
function build_javadoc() {
echo "creating javadoc files..."
local CLASSPATH="${JAR_ROOT}${SEP}${DEPENDENCIES}${SEP}${JAR_ROOT}/hadoop/${DEFAULT_HADOOP_VERSION}/*"
mkdir -p target/logs
"${JAVADOC}" -overview ${SRC}/overview.html -classpath "${CLASSPATH}" -d "${OUTDIR}"/javadoc -sourcepath "${SRC}" -subpackages hex:water >& target/logs/javadoc_build.log
}
function junit() {
echo "running JUnit tests..."
"$JAVA" -ea -cp ${JAR_FILE} water.Boot -mainClass water.JUnitRunner
}
if [ "$1" = "onlydoc" ]; then
build_javadoc
exit 0
fi
if [ "$1" = "noclean" ]; then
shift
else
clean
fi
if [ "$1" = "clean" ]; then exit 0; fi
build_classes
if [ "$1" = "compile" ]; then exit 0; fi
build_initializer
build_jar
build_src_jar
build_samples
if [ "$1" = "build" ]; then exit 0; fi
build_javadoc
if [ "$1" = "doc" ]; then exit 0; fi
junit