From josiahnoel at gmail.com Sat Jun 10 21:02:42 2023 From: josiahnoel at gmail.com (Josiah Noel) Date: Sat, 10 Jun 2023 17:02:42 -0400 Subject: Jlink Services Message-ID: Heya, I've been using Jlink lately to create application images, and I can't help but notice that I have to add my service provider modules manually. The current bind-services flag doesn't help me since I'm only interested in a few services and want to keep the image size down. Would it be possible to get a sort of "add-services" argument that would resolve all modules that provide the given service class? I'm thinking of something like: ``` jlink --module-path mods --add-modules com.comsumer --add-services com.provider.spi.ServiceClass ``` -- Cheers, Josiah. -------------- next part -------------- An HTML attachment was scrubbed... URL: From michal at kleczek.org Sun Jun 11 04:01:48 2023 From: michal at kleczek.org (=?utf-8?Q?Micha=C5=82_K=C5=82eczek?=) Date: Sun, 11 Jun 2023 06:01:48 +0200 Subject: Jlink Services In-Reply-To: References: Message-ID: --bind-services You're welcome :) Micha? > On 10 Jun 2023, at 23:03, Josiah Noel wrote: > > ? > Heya, I've been using Jlink lately to create application images, and I can't help but notice that I have to add my service provider modules manually. The current bind-services flag doesn't help me since I'm only interested in a few services and want to keep the image size down. > > Would it be possible to get a sort of "add-services" argument that would resolve all modules that provide the given service class? > > I'm thinking of something like: > > ``` > jlink --module-path mods --add-modules com.comsumer --add-services com.provider.spi.ServiceClass > ``` > > -- > Cheers, Josiah. From michal at kleczek.org Sun Jun 11 04:06:14 2023 From: michal at kleczek.org (=?utf-8?Q?Micha=C5=82_K=C5=82eczek?=) Date: Sun, 11 Jun 2023 06:06:14 +0200 Subject: Jlink Services In-Reply-To: References: Message-ID: <2A43054D-79E6-4B84-88AA-EE6A21F57FE3@kleczek.org> Ahh sorry. You know bind services and want to limit the providers. You can limit the set of observable modules with limit-modules and add-modules. There is also --suggest-providers option but documentation seems to be lacking. Micha? > On 11 Jun 2023, at 06:01, Micha? K?eczek wrote: > > ?--bind-services > > You're welcome :) > > Micha? > >> On 10 Jun 2023, at 23:03, Josiah Noel wrote: >> >> ? >> Heya, I've been using Jlink lately to create application images, and I can't help but notice that I have to add my service provider modules manually. The current bind-services flag doesn't help me since I'm only interested in a few services and want to keep the image size down. >> >> Would it be possible to get a sort of "add-services" argument that would resolve all modules that provide the given service class? >> >> I'm thinking of something like: >> >> ``` >> jlink --module-path mods --add-modules com.comsumer --add-services com.provider.spi.ServiceClass >> ``` >> >> -- >> Cheers, Josiah. From josiahnoel at gmail.com Sun Jun 11 04:31:58 2023 From: josiahnoel at gmail.com (Josiah Noel) Date: Sun, 11 Jun 2023 00:31:58 -0400 Subject: Jlink Services In-Reply-To: <2A43054D-79E6-4B84-88AA-EE6A21F57FE3@kleczek.org> References: <2A43054D-79E6-4B84-88AA-EE6A21F57FE3@kleczek.org> Message-ID: I know how to use --suggest-providers as well, my issue is that it's tedious to have to parse the output and manually add each module. It'd make my workflow a lot simpler if I could just name the service class and have jlink resolve all the modules that provide it. On Sun, Jun 11, 2023, 12:06 AM Micha? K?eczek wrote: > Ahh sorry. You know bind services and want to limit the providers. > > You can limit the set of observable modules with limit-modules and > add-modules. > There is also --suggest-providers option but documentation seems to be > lacking. > > Micha? > > > On 11 Jun 2023, at 06:01, Micha? K?eczek wrote: > > > > ?--bind-services > > > > You're welcome :) > > > > Micha? > > > >> On 10 Jun 2023, at 23:03, Josiah Noel wrote: > >> > >> ? > >> Heya, I've been using Jlink lately to create application images, and I > can't help but notice that I have to add my service provider modules > manually. The current bind-services flag doesn't help me since I'm only > interested in a few services and want to keep the image size down. > >> > >> Would it be possible to get a sort of "add-services" argument that > would resolve all modules that provide the given service class? > >> > >> I'm thinking of something like: > >> > >> ``` > >> jlink --module-path mods --add-modules com.comsumer --add-services > com.provider.spi.ServiceClass > >> ``` > >> > >> -- > >> Cheers, Josiah. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Alan.Bateman at oracle.com Mon Jun 12 08:56:23 2023 From: Alan.Bateman at oracle.com (Alan Bateman) Date: Mon, 12 Jun 2023 09:56:23 +0100 Subject: Jlink Services In-Reply-To: References: <2A43054D-79E6-4B84-88AA-EE6A21F57FE3@kleczek.org> Message-ID: <8dd71493-369d-cb56-2f7a-66c54b8c7c88@oracle.com> On 11/06/2023 05:31, Josiah Noel wrote: > I know how to use --suggest-providers as well, my issue is that it's > tedious to have to parse the output and manually add each module. > > > It'd make my workflow a lot simpler if I could just name the service > class and have jlink resolve all the modules that provide it. > As you've found, jlink doesn't do service binding by default. The assumption is that most jlink users wants fine control over the modules that go into the run-time image. The --suggest-providers option was to help fine tune of service providers to specify to jlink to include. As has been mentioned, there is --bind-services option if needed. Service binding is iterative to allow service provider modules themselves make use of services. Usages of --bind-services can therefore lead to run-time images include modules that is hard to explain, or developers fighting the option with --limit-modules. I think what you are asking for is a way to do one round of service binding. On the surface this may be okay but it might have the same issues as --bind-services in that some developer will want all services that provide an implementation of S except they want to exclude want P8 and P37. P8 may be required by some other module so it can't be excluded. It gets hard to explain. We went explored this area a bit in JDK 9 and converged on keeping it simple: let someone configuring the jlink command decide which service provide module to include. I'm not saying this shouldn't be re-visited, just trying to summarize why it is the case. -Alan From josiahnoel at gmail.com Mon Jun 12 12:20:28 2023 From: josiahnoel at gmail.com (Josiah Noel) Date: Mon, 12 Jun 2023 08:20:28 -0400 Subject: Jlink Services In-Reply-To: <8dd71493-369d-cb56-2f7a-66c54b8c7c88@oracle.com> References: <2A43054D-79E6-4B84-88AA-EE6A21F57FE3@kleczek.org> <8dd71493-369d-cb56-2f7a-66c54b8c7c88@oracle.com> Message-ID: Thanks for the explanation, it clears up why things are the way they are. Even so, I'm not necessarily interested in only the modules I'd get in a single "round." I'd like to add extra modules for the service classes I specify via an arg, even across multiple rounds. That is, my application module info doesn't have any `uses` statement, but some of the required dependencies have multiple uses statements. I'd like a way to resolve only the modules for specific spi classes, not all that the dependency uses. On Mon, Jun 12, 2023, 4:56 AM Alan Bateman wrote: > On 11/06/2023 05:31, Josiah Noel wrote: > > I know how to use --suggest-providers as well, my issue is that it's > > tedious to have to parse the output and manually add each module. > > > > > > It'd make my workflow a lot simpler if I could just name the service > > class and have jlink resolve all the modules that provide it. > > > > As you've found, jlink doesn't do service binding by default. The > assumption is that most jlink users wants fine control over the modules > that go into the run-time image. The --suggest-providers option was to > help fine tune of service providers to specify to jlink to include. > > As has been mentioned, there is --bind-services option if needed. > Service binding is iterative to allow service provider modules > themselves make use of services. Usages of --bind-services can therefore > lead to run-time images include modules that is hard to explain, or > developers fighting the option with --limit-modules. > > I think what you are asking for is a way to do one round of service > binding. On the surface this may be okay but it might have the same > issues as --bind-services in that some developer will want all services > that provide an implementation of S except they want to exclude want P8 > and P37. P8 may be required by some other module so it can't be > excluded. It gets hard to explain. > > We went explored this area a bit in JDK 9 and converged on keeping it > simple: let someone configuring the jlink command decide which service > provide module to include. I'm not saying this shouldn't be re-visited, > just trying to summarize why it is the case. > > -Alan > -------------- next part -------------- An HTML attachment was scrubbed... URL: