Skip to content

Commit

Permalink
allow using the {{HOME_DIR}} placeholder in jvmArgs and args
Browse files Browse the repository at this point in the history
  • Loading branch information
siordache committed Dec 16, 2020
1 parent f522ffb commit 09f7430
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion doc/user_guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,10 @@ to parse the templates, with the following variables available:
- jvmArgs
- args

The values in the *args* and *jvmArgs* lists may contain the placeholder `{{BIN_DIR}}`, which stands for the _bin_ directory of your custom runtime image.
The values in the *args* and *jvmArgs* lists may contain the following placeholders:

- `{{BIN_DIR}}` - the _bin_ directory of the custom runtime image
- `{{HOME_DIR}}` - user's home directory (`$HOME` on Unix-like systems, `%USERPROFILE%` on Windows)

You can include the value of an environment variable in a JVM argument by enclosing the name of the environment variable between `{{` and `}}`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,35 @@ class LaunchScriptGenerator {
'unixScriptTemplate.txt',
'unixScriptTemplate.txt',
'$DIR',
'$HOME',
'\\$$1'),
WINDOWS(
'.bat',
{LauncherData ld -> ld.windowsScriptTemplate},
'windowsScriptTemplate.txt',
'windowsScriptTemplateJavaw.txt',
'%~dp0',
'%USERPROFILE%',
'%$1%')

final String extension
final Function<LauncherData, File> templateProvider
final String defaultTemplate
final String defaultTemplateNoConsole
final String binDirPlaceholder
final String homeDirPlaceholder
final String envVarReplacement

Type(String extension, Function<LauncherData, File> templateProvider,
String defaultTemplate, String defaultTemplateNoConsole,
String binDirPlaceholder, String envVarReplacement) {
String binDirPlaceholder, String homeDirPlaceholder,
String envVarReplacement) {
this.extension = extension
this.templateProvider = templateProvider
this.defaultTemplate = defaultTemplate
this.defaultTemplateNoConsole = defaultTemplateNoConsole
this.binDirPlaceholder = binDirPlaceholder
this.homeDirPlaceholder = homeDirPlaceholder
this.envVarReplacement = envVarReplacement
}
}
Expand Down Expand Up @@ -112,6 +117,7 @@ class LaunchScriptGenerator {
adjusted = '"' + adjusted + '"'
}
adjusted = adjusted.replace('{{BIN_DIR}}', type.binDirPlaceholder)
adjusted = adjusted.replace('{{HOME_DIR}}', type.homeDirPlaceholder)
adjusted = adjusted.replaceAll(/\{\{([\w.]+)}}/, type.envVarReplacement)
return adjusted
}
Expand Down

0 comments on commit 09f7430

Please sign in to comment.