JDK-8217751 : jpackage messages and failures
  • Type: Bug
  • Component: tools
  • Sub-Component: jpackage
  • Affected Version: internal
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-01-24
  • Updated: 2019-03-22
  • Resolved: 2019-02-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
internalFixed
Related Reports
Relates :  
Description
With the commands:

jpackage -Djlink.debug=true create-image \
    --input out/artifacts \
    --output out \
    --limit-modules java.base \
    --strip-native-commands \
    --main-jar Jpackager-Hello-jar/Jpackager-Hello.jar \
    --class Main
 
And a pre-existing output directory the output is:

invalid option [-Djlink.debug=true]
Exception: java.io.IOException: Root Directory /ws/MyProjects/Jpackager-Hello/out/Main already exists and --force is not specified"
Error: Bundler "Linux Application Image" (linux.app) failed to produce a bundle.

Comments:

 - "invalid option" should be capitalized and have a colon separating it from the bad argument.

 - Processing should have stopped with the invalid argument and not continue.

 - The IOException class name should not be printed, the message should be sufficient. 

 - The "ROOT" directory should have a clear correspondence to the command line arguments as being the --input, --output, or --build-root.  It is a good thing that the full path name is printed.

 - The final "Error" is redundant with the other errors.

 - --force could be better named and be explicitly about the output directory.  perhaps --clean-output.


Comments
review: http://cr.openjdk.java.net/~herrick/8217751/
03-02-2019

There is not any consensus as to how to change the --force option. Although I agree it is not clear, I am leaving that alone at this time and implementing the other suggestions. Errors encountered at a low level are frequently displayed there, then the code returns indicating it failed. This fix allows the Bundlers to throw a PackagerException, (which may be wrapping another exception) and let the code at the top handle it, avoiding several cases of multiple messages. Totally invalid options will now exit with "Error: Invalid Option: [<option>] If an option is given that is not valid for the given mode and current platform, a warning will be shown and processing will continue such as: Warning: Option [<option>] is not supported in <mode> mode on this platform. webrev: pending M5 build: http://java.se.oracle.com:10065/mdash/jobs/aherrick-sandbox-20190201-0248-246661
01-02-2019

consideration to rename --force is moved to line item 5 in JDK-8217894
01-02-2019

A suggestion for --force; rename the option to --delete-output-dir to make it clear that it relates to the --output-dir option.
31-01-2019