-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·146 lines (127 loc) · 3.21 KB
/
run
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/sh
set -e
OPTION=$1
PLATFORM=`uname`
# function
function usage() {
echo $0 [run\|pack\|clean]
}
# function
function download_json_org {
curl -OL https://github.com/stleary/JSON-java/archive/20171018.tar.gz
tar -xvf 20171018.tar.gz
mkdir -p src/org/json
mv JSON-java-20171018/*.java src/org/json/
rm -rf JSON-java-20171018
rm -f 20171018.tar.gz
}
# function
function check_jre_jdk() {
if type -p java; then
_java=java
elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
_java="$JAVA_HOME/bin/java"
else
echo 'could not find Java Runtime Environment (JRE)'
exit
fi
if type -p javac; then
_javac=javac
elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/javac" ]]; then
_javac="$JAVA_HOME/bin/javac"
else
echo 'could not find Java Development Kit (JDK).'
exit
fi
if [[ "$_javac" ]]; then
javac_ver=$("$_javac" -version 2>&1 | awk '/javac/ {print $2}')
echo javac version "$javac_ver"
if [[ ! "$javac_ver" > "1.8.0" ]]; then
echo 'you need JDK 1.8 or later to build this software.'
exit
fi
fi
if [[ "$_java" ]]; then
java_ver=$("$_java" -version 2>&1 | awk -F '"' '/version/ {print $2}')
echo java version "$java_ver"
if [[ ! "$java_ver" > "1.8.0" ]]; then
echo 'you need JRE 1.8 or later to run this software.'
exit
fi
fi
}
# function
function clean_build_all() {
rm -rf build
mkdir -p ./build
cd src
javac -d ../build Remologue.java -Xlint
cd ../build
jar cvfe Remologue.jar Remologue .
cp -R ../resources .
cp ../.remologue ../resources/json/settings.json
cd resources
zip -ur ../Remologue.jar image
zip -ur ../Remologue.jar json
zip -ur ../Remologue.jar css
cd ..
}
# function
function macos_icns() {
cp resources/image/icon.png Remologue.png
mkdir Remologue.iconset
sips -z 512 512 Remologue.png --out Remologue.iconset/icon_512x512.png
iconutil --convert icns Remologue.iconset
mkdir -p package/macosx
cp Remologue.icns package/macosx
}
# function
function macos_pack() {
JAVA_HOME=`/usr/libexec/java_home -v 1.8`
APP_DIR_NAME=Remologue.app
javapackager \
-deploy \
-Bruntime=${JAVA_HOME} \
-Bicon=package/macosx/Remologue.icns \
-native image \
-srcdir . \
-srcfiles Remologue.jar \
-outdir deploy \
-outfile ${APP_DIR_NAME} \
-appclass Remologue \
-name "Remologue" \
-title "Remologue" \
-vendor "Remologue" \
-nosign \
-v
}
if [ -z $OPTION ];then
echo the script option is missing.
usage
exit
fi
if [ "$OPTION" == "clean" ];then
echo \'build\' has been removed.
rm -rf build
exit
fi
if [[ ! -d src/org/json ]];then
download_json_org
fi
check_jre_jdk
clean_build_all
# post compilation actions
if [ "$OPTION" == "pack" ];then
if [ "$PLATFORM" == "Darwin" ]; then
echo MacOS bundle will be created.
macos_icns
macos_pack
else
echo $PLATFORM is not supported yet.
fi
fi
if [ "$OPTION" == "run" ];then
cd ..
cp .remologue ~/
java -jar build/Remologue.jar & disown
fi