-
Notifications
You must be signed in to change notification settings - Fork 14
/
start.sh
executable file
·78 lines (69 loc) · 3.57 KB
/
start.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
## resolve folder of this script, following all symlinks:
## http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
SCRIPT_SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SCRIPT_SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
SCRIPT_DIR="$( cd -P "$( dirname "$SCRIPT_SOURCE" )" && pwd )"
SCRIPT_SOURCE="$(readlink "$SCRIPT_SOURCE")"
# if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
[[ $SCRIPT_SOURCE != /* ]] && SCRIPT_SOURCE="$SCRIPT_DIR/$SCRIPT_SOURCE"
done
readonly PORTABLE_JRD_HOME="$( cd -P "$( dirname "$SCRIPT_SOURCE" )" && pwd )"
if [ "x$JAVA_HOME" = "x" ] ; then
# Locate JDK from $PATH
javac_home=$(command -v javac)
javac_home=$(readlink -f "$javac_home")
javac_home="$(dirname "$(dirname "$javac_home")")"
else
javac_home="$JAVA_HOME"
fi
PURPOSE=DEVELOPMENT
MVN_SOURCE="$HOME/.m2/repository"
function findLib(){
if [ "x$PURPOSE" = "xDEVELOPMENT" ] ; then
local BASE="$MVN_SOURCE"
local GROUP="$1"
local FILENAME="$2"
else
local BASE="$PORTABLE_JRD_HOME/libs/deps"
local GROUP=""
local FILENAME="$2"
fi
local name=$(find "$BASE/$GROUP" | grep -v -e sources.jar -e javadoc.jar | sed "s;.*/;;" | grep "$FILENAME$" | sort -V | tail -n 1)
local result=$(find "$BASE/$GROUP" | grep -v -e sources.jar -e javadoc.jar | grep -e "/$name$" | sort -V | tail -n 1)
# only for build time! Useless in runtime; from image.sh
if [ "x$VERIFY_CP" = "xTRUE" ] ; then
verifyonCp "$result"
fi
echo $result
}
TOOLS="$javac_home"/lib/tools.jar #just jdk8 and down
readonly RSYNTAXTEXTAREA=$(findLib "com/fifesoft/rsyntaxtextarea" "rsyntaxtextarea-.*\.jar" )
readonly GSON=$(findLib "com/google/code/gson/gson" "gson-.*\.jar")
readonly JDIFF=$(findLib "io/github/java-diff-utils/java-diff-utils" "java-diff-utils-.*\.jar")
readonly ASM_TREE=$(findLib "org/ow2/asm/asm-tree" "asm-tree-.*\.jar")
readonly ASM_JAR=$(findLib "org/ow2/asm/asm" "asm-[0-9].*\.jar")
readonly BYTEMAN=$(findLib "org/jboss/byteman/byteman" "byteman-[[:digit:]].*\.jar")
readonly BYTEMAN_INSTALL=$(findLib "org/jboss/byteman/byteman-install" "byteman-install-.*\.jar")
readonly BYTEMAN_SUBMIT=$(findLib "org/jboss/byteman/byteman-submit" "byteman-submit-.*\.jar")
readonly CPLC_API=$(findLib "io/github/mkoncek/classpathless-compiler-api" "classpathless-compiler-api-.*\.jar")
readonly CPLC_UTIL=$(findLib "io/github/mkoncek/classpathless-compiler-util" "classpathless-compiler-util-.*\.jar")
readonly CPLC=$(findLib "io/github/mkoncek/classpathless-compiler" "classpathless-compiler-[[:digit:]].*\.jar")
readonly JUST_BUILD_JRD=`find "$PORTABLE_JRD_HOME/runtime-decompiler/target/" 2> /dev/null | grep "runtime-decompiler-.*\.jar" | grep -v "jar-with-dependencies" `
if [ -f "$JUST_BUILD_JRD" ] ; then
readonly JRD="$JUST_BUILD_JRD"
else
readonly JRD=$(findLib "java-runtime-decompiler/runtime-decompiler" "runtime-decompiler-[[:digit:]].*\.jar")
fi
if [ "x$THE_TERRIBLE_INTERNAL_JRD" == "xtrue" ] ; then
return 0
fi
readonly PROPERTY_LOCATION="-Djrd.location=$PORTABLE_JRD_HOME"
readonly PROPERTY_PURPOSE="-Djrd.purpose=$PURPOSE"
# launch application
"$javac_home"/bin/java -Djdk.attach.allowAttachSelf=true "$PROPERTY_LOCATION" "$PROPERTY_PURPOSE" \
--add-exports jdk.jdeps/com.sun.tools.javap=ALL-UNNAMED \
--add-opens java.base/java.lang=ALL-UNNAMED \
--add-opens java.base/java.io=ALL-UNNAMED \
-cp "$TOOLS:$JRD:$RSYNTAXTEXTAREA:$GSON:$JDIFF:$BYTEMAN:$BYTEMAN_INSTALL:$BYTEMAN_SUBMIT:$CPLC_API:$CPLC_UTIL:$CPLC:$ASM_TREE:$ASM_JAR" \
org.jrd.backend.data.Main "$@"