-
Notifications
You must be signed in to change notification settings - Fork 109
Optional Cache Directory
The cache dir option will override the directory the downloaded artifacts are placed in. By default, artifacts are placed in the current working directory. The program parameter --cache-dir
or the manifest entry cacheDir
can be specified to override this.
This feature can be helpful in several circumstances:
- If the application is installed in a placed where the user does not have write access
- If there is a problem with configuring the current working directory, as seen with some Mac Java Version
- To cache commonly used library files amongst several installed apps
The program parameter will override any configured value in the manifest, and the default will still be "the current working directory".
If you natively install your app for the whole system (the default if using an MSI, DMG, PKG, RPM, or DEB native package ), the app will require admin privleges to install, but might not run with enough admin privileges to write the downloaded files to the same installation location.
With the default cacheDir
value, FXLoader will try to cache the downloaded artifacts where it was installed—in this case, that system-wide folder—the problem is that it takes admin privileges to put things in that system-wide folder and, when launching, apps don't have enough privileges to put things in that system-wide folder (can: run things; can't: write things).
To get around this problem, we still install the app system-wide, but then tell it to put any updates it downloads somewhere it has permission to put them. Benefits: install once, access for everyone, automatic updates 🤓 .
There are at least two strategies and a magical string for each. The magical string will get replaced with the appropriate folder for the OS.
For when you want each user to have their own cache of dependencies.
If the cache dir parameter starts with the magical string USERLIB/
this string will be replaced with an OS-specific path corresponding to the place where user-level applications are installed—no admin privileges required.
Consider the following parameter values:
Command Line | Maven | Gradle |
---|---|---|
--cache-dir=USERLIB/MyApp |
<app.cacheDir>USERLIB/MyApp</app.cacheDir> |
cacheDir 'USERLIB/MyApp' |
The result will be:
OS | Location |
---|---|
Windows1 | %UserProfile%/AppData/Local/MyApp |
Mac2 | ~/Library/Application Support/MyApp |
Linux2 | ~/.MyApp |
1: Why the AppData folder? %UserProfile%
usually looks like C:/Users/{SomeUserName}
2: For the uninitiated the ~
symbol is a shortcut for the user's home directory on Mac/Unix systems
For when you want the whole system to share a single cache of dependencies.
If the cache dir parameter starts with the magical string ALLUSERS/
this string will be replaced with an OS-specific path corresponding to the location where system-wide-accessible files can be placed and removed—no admin privileges required.
Consider the following parameter values:
Command Line | Maven | Gradle |
---|---|---|
--cache-dir=ALLUSERS/MyApp |
<app.cacheDir>ALLUSERS/MyApp</app.cacheDir> |
cacheDir 'ALLUSERS/MyApp' |
The result will be:
OS | Location |
---|---|
Windows3 | %AllUsersProfile%/MyApp |
Mac | /Library/Application Support/MyApp |
Linux | /usr/local/share/MyApp |
3: %AllUsersProfile%
on modern Windows is C:/ProgramData
. Why the ProgramData folder?