-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpackage.sh
151 lines (132 loc) · 5.14 KB
/
package.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
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
147
148
149
150
151
#!/usr/bin/env bash
##
# Run this script as `bash package.sh` to build a native app.
# The script works on both UNIX and OSX platforms.
##
# Static variables
SRC_DIR=isopret-gui
APP_NAME="isopret-gui"
CMD_NAME="isopret-gui"
VERSION=1.0.0
BUILD_DIR=${SRC_DIR}/target
#JAR_NAME="isopret-gui-${VERSION}.jar"
JAR_NAME="isopret-gui.jar"
VENDOR="The Jackson Laboratory"
DESCRIPTION="Isopret-gui is a Java application for investigating and visualizing overrepresentation of Gene Ontology (GO) annotations in differentially spliced or differentially expressed genes."
COPYRIGHT="Copyright 2024, All rights reserved"
ICON="${BUILD_DIR}/classes/img/dna_rna_icon.ico"
function detect_platform() {
if [[ "$OSTYPE" == "linux-gnu" ]]; then
echo "Linux"
elif [[ "$OSTYPE" =~ darwin.* ]]; then
echo "Osx";
elif [[ "$OSTYPE" =~ "win64" ]]; then
echo "Windows";
else
# More people use OSX
echo "Osx"
fi
}
# The following function not used since isopret is not yet modular
function build_for_module_path() {
# copy the JAR and lib (dependencies)
cp $BUILD_DIR/$JAR_NAME $PACKAGE_DIR
cp -r $BUILD_DIR/lib $PACKAGE_DIR/lib
if [[ "$PLATFORM" == "Linux" ]]; then
# Setup Linux CLI using module path
MPATH="${PACKAGE_DIR}/lib:${PACKAGE_DIR}/${JAR_NAME}"
printf "Module path: %s\n" "${MPATH}"
MODULE="org.jax.isopret.app/org.jax.isopret_gui.App"
printf "Module %s\n" "${MODULE}"
DETECTED_MODULES=$(jdeps --multi-release 17 --ignore-missing-deps --print-module-deps --module-path "${MPATH}" ${PACKAGE_DIR}/${JAR_NAME})
printf "Detected modules: %s\n" "${DETECTED_MODULES}"
MANUAL_MODULES="jdk.localedata"
JAVA_RUNTIME=${PACKAGE_DIR}/java-runtime
printf "Building Java runtime to: %s\n" ${JAVA_RUNTIME}
#jlink --no-header-files --no-man-pages --compress=2 --strip-debug --module-path ${MPATH} --add-modules "${DETECTED_MODULES},${MANUAL_MODULES}" --include-locales=en --output ${JAVA_RUNTIME}
# jpackage --name "${APP_NAME}" --module-path "${MPATH}" --module "${MODULE}" --java-options -Xmx2048m --runtime-image ${JAVA_RUNTIME} --linux-menu-group Science --linux-shortcut --linux-package-name "${CMD_NAME}" --icon "${ICON}.png" --app-version "${VERSION}" --description "${DESCRIPTION}" --vendor "${VENDOR}" --license-file LICENSE --copyright "${COPYRIGHT}"
elif [[ "$PLATFORM" == "Osx" ]]; then
# setup OSX CLI using module path
#jpackage --name "${APP_NAME}" --input "${PACKAGE_DIR}" --main-jar "${JAR_NAME}" --mac-package-name "${CMD_NAME}" --icon "${ICON}.icns" --app-version "${VERSION}" --description "${DESCRIPTION}" --vendor "${VENDOR}" --license-file LICENSE --copyright "${COPYRIGHT}"
echo "Sorry, module path is not yet supported"
else
printf "Unknown platform %s\n. Abort." "${PLATFORM}"
exit
fi
}
function build_for_class_path() {
# copy the fat JAR
cp $BUILD_DIR/$JAR_NAME $PACKAGE_DIR
# cp $BUILD_DIR/lib/* $PACKAGE_DIR
if [[ "$PLATFORM" == "Linux" ]]; then
# setup Linux CLI
jpackage --name "${APP_NAME}" \
--input "${PACKAGE_DIR}" \
--main-jar "${JAR_NAME}" \
--app-version "${VERSION}" \
# --icon "${ICON}.ico" \
--description "${DESCRIPTION}" \
--linux-menu-group Science \
--linux-shortcut \
--linux-package-name "${CMD_NAME}" \
--vendor "${VENDOR}" \
--license-file LICENSE \
--copyright "${COPYRIGHT}"
#--main-class "org.monarchinitiative.hpo_case_annotator.app.App" \
elif [[ "$PLATFORM" == "Osx" ]]; then
# setup OSX CLI
jpackage --name "${APP_NAME}" \
--input "${PACKAGE_DIR}" \
--main-jar "${JAR_NAME}" \
--app-version "${VERSION}" \
--description "${DESCRIPTION}" \
--mac-package-name "${CMD_NAME}" \
--vendor "${VENDOR}" \
--license-file LICENSE \
--copyright "${COPYRIGHT}"
# --icon "${ICON}.icns" \
elif [[ "$PLATFORM" == "Windows" ]]; then
# setup OSX CLI
jpackage --name "${APP_NAME}" \
--input "${PACKAGE_DIR}" \
--main-jar "${JAR_NAME}" \
--app-version "${VERSION}" \
--description "${DESCRIPTION}" \
--windows-package-name "${CMD_NAME}" \
--vendor "${VENDOR}" \
--license-file LICENSE \
--copyright "${COPYRIGHT}" \
--win-console
# --icon "${ICON}.icns" \
else
printf "Unknown platform %s\n. Abort." "${PLATFORM}"
exit
fi
}
##
# Dynamic variables
#
PLATFORM=$(detect_platform)
PACKAGE="classpath"
#PACKAGE="modular"
# 1. Build
printf "Building isopret-gui\n"
./mvnw clean package
# 2. Prepare packaging folder
PACKAGE_DIR=/tmp/isopret_app
printf "Creating temporary directory at %s\n" ${PACKAGE_DIR}
mkdir -p $PACKAGE_DIR
# 3. Package for platform and package type
if [[ "$PACKAGE" == "modular" ]]; then
printf "Packaging modular isopret-gui for %s\n" "${PLATFORM}"
build_for_module_path
elif [[ "$PACKAGE" == "classpath" ]]; then
printf "Packaging classpath isopret-gui for %s\n" "${PLATFORM}"
build_for_class_path
else
printf "\nUnknown packaging type '%s'\n" "${PACKAGE}"
fi
# 4. Clean up the packaging folder
printf "Removing the temporary directory %s\n" ${PACKAGE_DIR}
rm -r $PACKAGE_DIR
printf "Done!\n"