jlink --add-modules not applied to launcher

Eirik Bjørsnøs eirbjo at gmail.com
Tue Apr 25 15:14:55 UTC 2023


On Tue, Apr 25, 2023 at 2:48 PM Alan Bateman <Alan.Bateman at oracle.com>
wrote:

> The command line parsing in jlink doesn't currently allow the argument for
> a plugin use GNU style options. There are workarounds, e.g. `--add-options
> \ --add-modules=foo,bar` so you mileage might vary on this.
>

I'm calling jlink through its ToolProvider and it does indeed work to
simply add a space just before --add-modules=, like this:

String[] options = new String[] {"--add-options", " --add-modules="
+String.join(",", addModules), ...};

The leading space makes following check of the --add-options param value in
TaskHelper.OptionsHelper not match and throw BadArgs:

if (param == null || param.isEmpty()
>         || (param.length() >= 2 && param.charAt(0) == '-'
>         && param.charAt(1) == '-')) {
>     throw new BadArgs("err.missing.arg", name).
>             showUsage(true);
> }


The logic here could probably be improved.

Thanks,
Eirik.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jigsaw-dev/attachments/20230425/28c7a417/attachment-0001.htm>


More information about the jigsaw-dev mailing list