Skip to content

Commit 14f3b0f

Browse files
committed
Expand variables $APP_PACKAGE, $APP_ROOT, $JAVAROOT and $USER_HOME in both - Apple and Oracle style - Plist files
1 parent 3339f69 commit 14f3b0f

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88

99
## [Unreleased]
10+
### Added
11+
- Also expand variables `$APP_PACKAGE`, `$JAVAROOT` and `$USER_HOME` in Oracle style PList files
12+
- Also expand variable `$APP_ROOT` in Apple style PList files
13+
1014
### Changed
1115
- Improved language detection by reading the user preferred languages from the macOS System Preferences instead of using the system locale (#101)
1216
- Improved logging for JAVA_HOME detection (#100)

src/universalJavaApplicationStub

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ if [ $exitcode -eq 0 ]; then
166166
JavaFolder="${AppleJavaFolder}"
167167
ResourcesFolder="${AppleResourcesFolder}"
168168

169+
# set expandable variables
170+
APP_ROOT="${AppPackageFolder}"
169171
APP_PACKAGE="${AppPackageFolder}"
170172
JAVAROOT="${AppleJavaFolder}"
171173
USER_HOME="$HOME"
@@ -180,7 +182,7 @@ if [ $exitcode -eq 0 ]; then
180182
# AppPackageRoot is the standard WorkingDirectory when the script is started
181183
WorkingDirectory="${AppPackageRoot}"
182184
fi
183-
# expand variables $APP_PACKAGE, $JAVAROOT, $USER_HOME
185+
# expand variables $APP_PACKAGE, $APP_ROOT, $JAVAROOT, $USER_HOME
184186
WorkingDirectory=$(eval echo "${WorkingDirectory}")
185187

186188

@@ -203,7 +205,7 @@ if [ $exitcode -eq 0 ]; then
203205
else
204206
JVMClassPath=${JVMClassPath_RAW}
205207
fi
206-
# expand variables $APP_PACKAGE, $JAVAROOT, $USER_HOME
208+
# expand variables $APP_PACKAGE, $APP_ROOT, $JAVAROOT, $USER_HOME
207209
JVMClassPath=$(eval echo "${JVMClassPath}")
208210

209211
# read the JVM Options in either Array or String style
@@ -213,7 +215,7 @@ if [ $exitcode -eq 0 ]; then
213215
else
214216
JVMDefaultOptions=${JVMDefaultOptions_RAW}
215217
fi
216-
# expand variables $APP_PACKAGE, $JAVAROOT, $USER_HOME (#84)
218+
# expand variables $APP_PACKAGE, $APP_ROOT, $JAVAROOT, $USER_HOME (#84)
217219
JVMDefaultOptions=$(eval echo "${JVMDefaultOptions}")
218220

219221
# read StartOnMainThread and add as -XstartOnFirstThread
@@ -247,7 +249,11 @@ else
247249
ResourcesFolder="${OracleResourcesFolder}"
248250
WorkingDirectory="${OracleJavaFolder}"
249251

252+
# set expandable variables
250253
APP_ROOT="${AppPackageFolder}"
254+
APP_PACKAGE="${AppPackageFolder}"
255+
JAVAROOT="${OracleJavaFolder}"
256+
USER_HOME="$HOME"
251257

252258
# read the MainClass name
253259
JVMMainClass="$(plist_get ':JVMMainClassName')"
@@ -265,12 +271,12 @@ else
265271
JVMClassPath_RAW=$(plist_get ':JVMClassPath')
266272
if [[ $JVMClassPath_RAW == *Array* ]] ; then
267273
JVMClassPath=.$(plist_get ':JVMClassPath' | grep " " | sed 's/^ */:/g' | tr -d '\n' | xargs)
268-
# expand variables $APP_PACKAGE, $JAVAROOT, $USER_HOME
274+
# expand variables $APP_PACKAGE, $APP_ROOT, $JAVAROOT, $USER_HOME
269275
JVMClassPath=$(eval echo "${JVMClassPath}")
270276

271277
elif [[ ! -z ${JVMClassPath_RAW} ]] ; then
272278
JVMClassPath=${JVMClassPath_RAW}
273-
# expand variables $APP_PACKAGE, $JAVAROOT, $USER_HOME
279+
# expand variables $APP_PACKAGE, $APP_ROOT, $JAVAROOT, $USER_HOME
274280
JVMClassPath=$(eval echo "${JVMClassPath}")
275281

276282
else
@@ -316,14 +322,14 @@ fi
316322
stub_logger "[JavaRequirement] JVM minimum version: ${JVMVersion}"
317323
stub_logger "[JavaRequirement] JVM maximum version: ${JVMMaxVersion}"
318324

319-
# MainArgs: replace occurences of $APP_ROOT with its content
325+
# MainArgs: expand variables $APP_PACKAGE, $APP_ROOT, $JAVAROOT, $USER_HOME
320326
MainArgsArr=()
321327
for i in "${MainArgs[@]}"
322328
do
323329
MainArgsArr+=("$(eval echo "$i")")
324330
done
325331

326-
# JVMOptions: replace occurences of $APP_ROOT with its content
332+
# JVMOptions: expand variables $APP_PACKAGE, $APP_ROOT, $JAVAROOT, $USER_HOME
327333
JVMOptionsArr=()
328334
for i in "${JVMOptions[@]}"
329335
do

0 commit comments

Comments
 (0)