-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild-native-image.sh
56 lines (45 loc) · 1.69 KB
/
build-native-image.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
#!/bin/bash
# If you need to change permissions for execution then do: sudo chmod 775 build-native-image.sh
# NOTE: you first need to build the signaling project and generate the JAR artifact targeting Java 11 or higher. Update pom.xml accordingly.
if [ -z "$GRAALVM_HOME" ] ; then
echo "Please set GRAALVM_HOME to point to your graalvm installation"
exit
fi
# build spring-native project
echo === Building spring-native
cd target/spring-native/spring-native
mvn clean package
cd ../../..
export JAR="signaling.jar"
# decompress jar file to get a classpath with jars and classes
echo === Decompressing $JAR file to build a classpath with jars and classes
rm -rf target/graal-build 2> /dev/null
mkdir target/graal-build
cd target/graal-build
jar -xf ../$JAR
cp -R META-INF BOOT-INF/classes
# remove native-image folder because it is later read from the JAR file
rm -rf BOOT-INF/classes/META-INF/native-image 2> /dev/null
rm -rf META-INF/native-image 2> /dev/null
# build classpath with all jars and classes
cd WEB-INF/classes
export LIBPATH_1=`find ../lib | tr '\n' ':'`
export CP=.:$LIBPATH_1
# go back to graal-build folder
cd ../..
# spring-graal-native jar being on the classpath is what triggers the Spring Graal auto configuration.
export CP=$CP:../spring-native/spring-native/target/spring-native-0.11.1-SNAPSHOT.jar
# compile with graal native-image
echo === Compiling with graal native-image
$GRAALVM_HOME/bin/native-image \
-cp $CP \
-jar ../$JAR \
-H:Class=org.fabri1983.signaling.SignalingEntryPoint
#$GRAALVM_HOME/bin/native-image --server-shutdown
if [[ $? -eq 0 ]] ; then
echo === Native image located at target/graal-build/
else
echo === Failed!
fi
# let's go back to project base dir
cd ../..