forked from OpenNMS/unbound4j
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·46 lines (37 loc) · 1007 Bytes
/
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
#!/bin/bash -e
if [ ! -e build.sh ]; then
echo "build.sh must be ran from the root of the project."
exit 1
fi
for DIR in /usr/lib/jvm/java-7-openjdk-*; do
if [ -d "$DIR" ] && [ -x "$DIR"/bin/javac ]; then
export JAVA_HOME="$DIR"
fi
done
which cmake >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "You must install cmake first."
exit 1
fi
which mvn >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "You must install maven first."
exit 1
fi
# Cleanup
pushd . && rm -rf build dist && mkdir build
# Generate the JNI interface header
cd ./java
mvn clean compile
# Build the shared library
cd ../build
cmake ../jni/
make
# Copy the shared library over to the Java build
mkdir -p ../java/src/main/resources/org/opennms/unbound4j/native/linux-x86_64/
cp ../dist/libunbound4j.so ../java/src/main/resources/org/opennms/unbound4j/native/linux-x86_64/
# Run the tests and create the .jar
cd ../java
mvn install -DskipTests=true || (echo "Build failed." && exit 1)
cp target/unbound4j-*.jar ../dist/
popd