]> git.evergreen-ils.org Git - working/Hatch.git/blob - hatch.sh
LP#1646166 Hatch dev install docs continued
[working/Hatch.git] / hatch.sh
1 #!/bin/bash
2 #
3 # Linux/Mac Hatch Execution Script
4
5 JAVA_HOME=jdk1.8
6 JAVA=$JAVA_HOME/bin/java
7 JAVAC=$JAVA_HOME/bin/javac
8 JAR=$JAVA_HOME/bin/jar
9 LOGS=-Djava.util.logging.config.file=logging.properties
10 JSON_BUILD="20160810"
11 JSON_JAR="json-$JSON_BUILD.jar"
12 JSON_URL="https://search.maven.org/remotecontent?filepath=org/json/json/$JSON_BUILD/$JSON_JAR"
13
14 COMMAND="$1"
15
16 if [ "$COMMAND" == "compile" ]; then
17
18     mkdir -p lib
19     if [ ! -f lib/$JSON_JAR ]; then
20         echo "Fetching JSON libs..."
21         wget -O lib/$JSON_JAR $JSON_URL
22     fi;
23
24     $JAVAC -Xdiags:verbose -Xlint:unchecked \
25         -cp lib/\* -d lib src/org/evergreen_ils/hatch/*.java
26
27     # Create a JAR file from the compiled class files them remove them.
28     $JAR cf lib/hatch.jar -C lib org
29     rm -r lib/org
30
31 elif [ "$COMMAND" == "test" ]; then
32
33     # 1. Run TestHatch in (default) send mode, which emits JSON requests
34     # 2. Run Hatch and process messages emitted from #1.
35     # 3. Run TestHatch in receive mode to log the responses.
36
37     $JAVA "$LOGS" -cp lib/\* org.evergreen_ils.hatch.TestHatch \
38         | $JAVA "$LOGS" -cp lib/\* org.evergreen_ils.hatch.Hatch \
39         | $JAVA "$LOGS" -cp lib/\* org.evergreen_ils.hatch.TestHatch receive
40
41 else
42
43     # run Hatch
44     $JAVA "$LOGS" -cp lib/\* org.evergreen_ils.hatch.Hatch
45 fi;