JDK-8287060 : Allow per-user and system wide configuration of a jpackaged app
  • Type: CSR
  • Component: tools
  • Sub-Component: jpackage
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 19
  • Submitted: 2022-05-20
  • Updated: 2022-06-03
  • Resolved: 2022-06-01
Related Reports
CSR :  
Relates :  
Description
Summary
-------

Support both system-wide and per-user configuration of a jpackaged application.

Problem
-------

There is no way to set per-user startup parameters for application launchers for installed jpackaged applications. 

Installation of jpackaged application is system-wide.
Configurations parameters are stored in `.cfg` property files in the system-wide installation directory thus only system-wide configuration is supported. 
In some cases user-specific startup parameters need to be specified. Currently, there is no way to do it because startup parameters are stored in the system-wide installation location.

Solution
--------

Add support to jpackage application launcher to look up the corresponding `.cfg` file not only in the application installation directory (the system-wide installation location) but also in user-specific locations.

Specification
-------------

Application launcher of the installed application will look up the corresponding `.cfg` file in user-specific directories. If `.cfg` file is not found, the application launcher will load `.cfg` file from the installation directory.
Application launcher executed from application image, i.e. not from the installed application will not look up the corresponding `.cfg` file in user-specific directories. It will load the corresponding `.cfg` file from the application image directory.

User-specific directories for `.cfg` file look up will be:

## Linux

 1. `~/.local/${PACKAGE_NAME}`
 2. `~/.${PACKAGE_NAME}`

## macOS

 1. `~/Library/Application Support/${PACKAGE_NAME}`

## Windows

 1. `%LocalAppData%\%PACKAGE_NAME%`
 2. `%AppData%\%PACKAGE_NAME%`

`${PACKAGE_NAME}` and `%PACKAGE_NAME%` refer to jpackaged application name.

E.g.: for a fictional application named `Duke` main application launcher will use the first existing `.cfg` file from the list:

## Linux

 1. `~/.local/duke/Duke.cfg`
 2. `~/.duke/Duke.cfg`
 3. `/opt/duke/lib/app/Duke.cfg`

## macOS

 1. `~/Library/Application Support/Duke/Duke.cfg`
 2. `/Applications/Duke.app/Contents/app/Duke.cfg`

## Windows

 1. `%LocalAppData%\Duke\Duke.cfg`
 2. `%AppData%\Duke\Duke.cfg`
 3. `%ProgramFiles%\Duke\app\Duke.cfg`

E.g.: for a fictional application named `Duke` additional application launcher named `other-duke` will use the first existing `.cfg` file from the list:

## Linux

 1. `~/.local/duke/other-duke.cfg`
 2. `~/.duke/other-duke.cfg`
 3. `/opt/duke/lib/app/other-duke.cfg`

## macOS

 1. `~/Library/Application Support/Duke/other-duke.cfg`
 2. `/Applications/Duke.app/Contents/app/other-duke.cfg`

## Windows

 1. `%LocalAppData%\Duke\other-duke.cfg`
 2. `%AppData%\Duke\other-duke.cfg`
 3. `%ProgramFiles%\Duke\app\other-duke.cfg`

Comments
Moving to Approved.
01-06-2022

Moving to Provisional.
27-05-2022

Sure. Will also create a RN.
24-05-2022

As long as it's documented somewhere that might be sufficient. Joe might have an opinion as to whether a release note is in a good idea. I can see value in a release note.
24-05-2022

No plans to support disabling of user .cfg file. I didn't think about RN. Would adding details about this feature to jpackage man page be a better alternative?
24-05-2022

Is there a way to override this behavior and ignore a user .`cfg` file? I presume not, which seems fine to me. I think this deserves a release note. Where else will this be documented?
24-05-2022

1) Users will manually create cfg files if they would like to customize the startup parameters of specific app launchers. They can copy/paste specific cfg files from the system-wide installation location and adjust them. 2) "System-wide" and "app bundle installation location" are synonyms and refer to the same directory in the file system. I've updated the description to make it explicit.
24-05-2022