jdeps output is not friendly for jlink --add-modules option to use. Provide a new option to print the module dependences in a comma-separated list.
jlink --add-modules argument takes a comma-separated list of root modules. An existing jdeps --list-deps output can be used to identify the modules required for an application but it is designed to assist developers to find the module dependences and also any JDK internal APIs that can be used to include in @modules in JDK regression tests and also --add-exports option to break into encapsulation as a temporary workaround to migrate to JDK 9. The primary usage for jdeps --list-deps is different and introducing a new option seems reasonable.
Provide a new jdeps --print-module-deps option that will print the module dependences in a comma-separated list. To create a custom image for myapp.jar, one can do:
$ jlink --module-path jmods --add-modules $(jdeps --print-module-deps myapp.jar)
A side note: jdeps is static analysis tool and so any module required due to reflection will have to be added to the jlink command explicitly. Similarly service providers should be specified to jlink --add-modules option
--list-deps Lists the module dependences. It also prints any JDK internal API packages if referenced. This option does not show dependences on the class path or not found. --list-reduced-deps Same as --list-deps with not listing the implied reads edges from the module graph. If module M1 reads M2, and M2 requires transitive on M3, then M1 reading M3 is implied and is not shown in the graph. --print-module-deps Same as --list-reduced-deps with printing a comma-separated list of module dependences. This output can be used by jlink --add-modules in order to create a custom image containing those modules and their transitive dependences.