Thanks for the info.
This is for my update to the
For now, all the providers are in that plugin, but someone could implement their own provider in another plugin.
I thought I needed something like an SPI, because, e.g., I want to support tasks like
KotlinCompile (which is in the Kotlin plugin, not Gradle core) in my plugin. I would prefer if users could apply my plugin, and if the Kotlin plugin is also applied, then my plugin will automatically support it. But, if the Kotlin plugin isn’t applied to the build, the build should complete without errors and without downloading otherwise-unnecessary jars.
There are a few ways to achieve this, but the cleanest I imagined was to use an SPI;
ServiceLoader is the built-in way to do that in Java SE.
I prefer not having a jigsaw-java plugin, plus a jigsaw-kotlin plugin, plus a jigsaw-scala plugin, etc. It will be simpler for users if they can just apply a jigsaw plugin that handles many languages / plugin tasks.
Also, a third-party could implement jigsaw compatibility for another plugin by creating a provider for my SPI. They could either put it directly in the affected plugin, if they control its source (e.g., JetBrains & the Kotlin plugin), or they could make a third-party plugin that applies both the main jigsaw plugin and the plugin to be affected (e.g., some random dev wants to add jigsaw support for plugin X, but they are not in control of the source for X).
Potentially, they could submit a PR, and their provider could then be incorporated into the main jigsaw plugin (or it could be left out in a separate plugin if the maintainers of the jigsaw plugin don’t want to include it).
Is there any way other than an SPI to achieve this? Is there any mechanism for an SPI that is better than
If I just have a provider registration method, wouldn’t that prevent me from having optional Kotlin plugin support in the main jigsaw plugin without requiring the Kotlin plugin to always be downloaded (and potentially requiring that it be applied)? Wouldn’t I have to split it out into a separate plugin?
If I were to have such a provider registration method, would I call it from the
apply(Project) method of the additional plugin?