1 | #!/bin/bash
|
---|
2 |
|
---|
3 | package=TDBJava
|
---|
4 | version=
|
---|
5 |
|
---|
6 | progname=$0
|
---|
7 |
|
---|
8 | source ../cascade-make/lib/cascade-lib.bash GEXTTDBEDIT ../.. $*
|
---|
9 |
|
---|
10 | STARTTS=`date +"%s.%3N"`
|
---|
11 | echo
|
---|
12 | echo "========= Compiling TDBJava ========="
|
---|
13 | # Check for existing JAR... skip if it's already there!
|
---|
14 | JARPATH="${GEXTTDBEDIT_INSTALLED}/lib/TDBJava.jar"
|
---|
15 | if [ -e "${JARPATH}" ]; then
|
---|
16 | echo " * TDBJava library already compiled. To recompile, remove: ${JARPATH}"
|
---|
17 | else
|
---|
18 | # Ensure Greenstone3 home is set
|
---|
19 | if [ -z "${GSDL3HOME}" ]; then
|
---|
20 | echo "Error! GSDL3HOME environment variable not set... have you run gs3-setup.sh in installed GSDL3 directory."
|
---|
21 | exit 1
|
---|
22 | fi
|
---|
23 | echo " Found GSDL3HOME: ${GSDL3HOME}"
|
---|
24 | WEBLIB="${GSDL3HOME}/WEB-INF/lib"
|
---|
25 | echo " Found GSDL3 web library: ${WEBLIB}"
|
---|
26 | # Ensure we have access to JAVAC
|
---|
27 | if [ -z "${JAVA_HOME}" ]; then
|
---|
28 | echo "Error! JAVA_HOME environment variable not set. Verify Java is installed and export JAVA_HOME to point to location."
|
---|
29 | exit 1
|
---|
30 | fi
|
---|
31 | echo " Found JAVA_HOME: ${JAVA_HOME}"
|
---|
32 | # And also that the path to the installed files for TDBEdit has been set
|
---|
33 | if [ -z "${GEXTTDBEDIT}" ]; then
|
---|
34 | echo "Error! GEXTTDBEDIT not set"
|
---|
35 | exit 1
|
---|
36 | fi
|
---|
37 | echo " Found GEXTTDBEDIT: ${GEXTTDBEDIT}"
|
---|
38 | echo " Found GEXTTDBEDIT_INSTALLED: ${GEXTTDBEDIT_INSTALLED}"
|
---|
39 | # Ensure the we have a class version of FlatDatabaseWrapper
|
---|
40 | if [ ! -f "${WEBLIB}/gsdl3.jar" ]; then
|
---|
41 | echo "Error! Greenstone3 JAR not available. Change to '${GSDL3HOME}' and run 'ant'"
|
---|
42 | exit 1
|
---|
43 | fi
|
---|
44 | echo " Found GSDL3 library: ${WEBLIB}/gsdl3.jar"
|
---|
45 | # And that we have a log4j jar
|
---|
46 | pushd "${WEBLIB}"
|
---|
47 | log4jjar=`find * -name "log4j-?.?.?.jar" 2>&1`
|
---|
48 | popd
|
---|
49 | if [ "${log4jjar}x" == "x" ]; then
|
---|
50 | echo "Error! No Log4J JAR available in: ${WEBLIB}'"
|
---|
51 | exit 1
|
---|
52 | fi
|
---|
53 | echo " Found Log4J library: ${WEBLIB}/${log4jjar}"
|
---|
54 | CLASSPATH=`mktemp -d 2>/dev/null || mktemp -d -t 'tdbjava'`
|
---|
55 | echo " * Created temporary directory for classes: ${CLASSPATH}"
|
---|
56 | # Compiling the TDBJava code itself is straightforward
|
---|
57 | # The TDBWrapper, unfortunately, needs a bit more work as it needs a class path
|
---|
58 | # to Apache and GSDL3 class files
|
---|
59 | SOURCEPATH="${GEXTTDBEDIT}/src/java/org/greenstone/tdbjava"
|
---|
60 | CWD=`pwd`
|
---|
61 | cd "${SOURCEPATH}"
|
---|
62 | `javac -cp "${WEBLIB}/${log4jjar}:${WEBLIB}/gsdl3.jar" -d ${CLASSPATH} *.java`
|
---|
63 | cd "${CWD}"
|
---|
64 | echo " * Compiled source files to classes"
|
---|
65 | `jar -cvf "${JARPATH}" -C ${CLASSPATH}/ . 2>&1 > /dev/null`
|
---|
66 | echo " * Gathered class files into JAR archive: ${JARPATH}"
|
---|
67 | `rm ${CLASSPATH}/org/greenstone/tdbjava/*.class`
|
---|
68 | `rmdir ${CLASSPATH}/org/greenstone/tdbjava`
|
---|
69 | `rm ${CLASSPATH}/org/greenstone/gsdl3/util/*.class`
|
---|
70 | `rmdir ${CLASSPATH}/org/greenstone/gsdl3/util`
|
---|
71 | `rmdir ${CLASSPATH}/org/greenstone/gsdl3`
|
---|
72 | `rmdir ${CLASSPATH}/org/greenstone`
|
---|
73 | `rmdir ${CLASSPATH}/org`
|
---|
74 | `rmdir ${CLASSPATH}`
|
---|
75 | echo " * Removed temporary directory"
|
---|
76 | fi
|
---|
77 | # Print out a nice duration message
|
---|
78 | ENDTS=`date +"%s.%3N"`
|
---|
79 | # HACK - ensure that BC prints the answer with a leading 0 before the point
|
---|
80 | ELAPSED=`echo "scale=3;x=${ENDTS}-${STARTTS};if (x<1) print 0;x" | bc`
|
---|
81 | echo "===== Complete in ${ELAPSED} seconds! ====="
|
---|
82 | echo
|
---|
83 | exit 0
|
---|