-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakesurefile
executable file
·83 lines (61 loc) · 2.37 KB
/
Makesurefile
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
# vim: syntax=bash
@options timing
#@define GRAAL "$HOME/.sdkman/candidates/java/21.3.0.r17-grl"
@define GRAAL "$HOME/.sdkman/candidates/java/22.2.r17-grl"
#@define GRAAL "$HOME/.sdkman/candidates/java/21.3.0.r11-grl"
@define UPX_HOME "$HOME/soft/upx-3.95-amd64_linux" # TODO via soft folder
@goal build_folder_created @private
@reached_if [[ -d ./build ]]
mkdir ./build
@goal graal_native_installed @private
@reached_if [[ -f $GRAAL/bin/native-image ]]
echo "Installing native-image..."
cd "$GRAAL/bin/"
./gu install native-image
@goal javac @private
export JAVA_HOME="$GRAAL"
graal_version=$($GRAAL/bin/java -version 2>&1 | grep '64' | grep GraalVM | sed -E 's#.+(GraalVM.+) \(.+#\1#')
java_version=$($GRAAL/bin/java -version 2>&1 | head -n 1 | sed 's/ version//' | sed 's/"//g')
echo "Java version: $java_version"
echo "Graal version: $graal_version"
mvn clean compile
app_version=$(mvn -q exec:exec -Dexec.executable=echo -Dexec.args='${project.version}')
tmp_src_dir=/tmp/serv-tmp
rm -rf $tmp_src_dir
mkdir -p $tmp_src_dir/com/cmlteam/serv
cat src/main/java/com/cmlteam/serv/Constants.java | \
sed "s/%GRAAL_VERSION%/$graal_version/" | \
sed "s/%JAVA_VERSION%/$java_version/" | \
sed "s/%APP_VERSION%/$app_version/" > $tmp_src_dir/com/cmlteam/serv/Constants.java
$GRAAL/bin/javac \
-encoding UTF-8 \
-d target/classes \
$tmp_src_dir/com/cmlteam/serv/Constants.java
@goal built_native @private
@depends_on build_folder_created graal_native_installed javac
CP=$(mvn -q exec:exec -Dexec.executable=echo -Dexec.args="%classpath")
cd ./build/
$GRAAL/bin/native-image -cp "$CP" com.cmlteam.serv.Serv \
--add-modules jdk.httpserver \
-H:IncludeResources='.*ico$' \
-H:Log=registerResource: # --native-image-info --verbose
ls -lh ./com.cmlteam.serv.serv
@goal upx @private
cd ./build/
rm -f ./serv
$UPX_HOME/upx ./com.cmlteam.serv.serv -oserv
ls -lh ./serv
./serv --version
@goal built
@depends_on built_native upx
@goal default
@depends_on built
@goal runH
@doc 'run help'
mvn compile exec:java -Dexec.mainClass="com.cmlteam.serv.Serv" -Dexec.args="-h"
@goal run2
@doc 'sample run 2 files'
mvn compile exec:java -Dexec.mainClass="com.cmlteam.serv.Serv" -Dexec.args="doc.txt img.png"
@goal runF
@doc 'sample run folder'
mvn compile exec:java -Dexec.mainClass="com.cmlteam.serv.Serv" -Dexec.args="."