You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[MNG-7921] Allow plugins to control classpath extensions #8997
It's great that a plugin (or extension jar) can have <exportedPackages> (specifically I want to use Google Guice in a plugin and this seems to be the only way), but it can only be applied globally AFAIK, so all plugins get the same exported packages and there might consequently be conflicts. It would be nice if a plugin that declared it was an extension could elect to specify exported packages independent of other plugins.
just to give a bit more context on the problem we face:
We are developing an extension/library that will allow the usage of spring libraries in maven plugins.
This can be done by defining a custom Guice module so that the objects managed by the spring container be injected into SISU.
But the definition of the custom Guice module currently requires exposing the Guice API from maven core to the external world (using the META-INF/maven/extension.xml)
And this can only be done with a core extension.
if we put the custom module in the same extension that exports the Guice API, the custom module will be run in the beginning of the maven lifecycle (in the initialization of the Core class-world because its a core extension) where there is no plugin information yet. This module will also be exposed to all plugin class-worlds that will inherit from this core class-world. This can cause issues to plugins that does not require the custom module.
If we put the custom module as a dependency to a plugin that requires it only, and the the META-INF/maven/extension.xml file in a separate core extension, the module will exist only in the chosen plugin class-world. But this has the disadvantage of asking all applications using such plugins that use custom Guice modules to define and activate the extension that contains the META-INF/maven/extension.xml file.
I see two solutions:
Exposing the Guice API by default. But this must be extensively tested to be sure we do not break something existing.
As David suggests, allowing plugins to define extensions for their own class-world only, or define their own exported APIs from the Core class-loader (probably requires creating a specific API class-loader).
A core extension is by definition something that we would like it to impact all plugins, or at least more than one.
So IMHO allowing plugins to define their own extensions is not the way to go. We can maybe consider the other way around. Giving extensions the ability to target specific plugins.
Via configurations maybe like defined in MNG-5897
Or just specify a new config file for plugins to allow their classloader be created by exporting specific apis from the core class-loader. Smth like the below
Tamas Cservenak do you think it is feasible to export the Guice API from maven core by default ? Should I create a discussion thread in dev mailing list ? please let me know, I do not know if a Jira is the best place to discuss.
Activity
jira-importer commentedon Jun 30, 2024
Ozgun OZ commented
just to give a bit more context on the problem we face:
We are developing an extension/library that will allow the usage of spring libraries in maven plugins.
This can be done by defining a custom Guice module so that the objects managed by the spring container be injected into SISU.
But the definition of the custom Guice module currently requires exposing the Guice API from maven core to the external world (using the META-INF/maven/extension.xml)
And this can only be done with a core extension.
I see two solutions:
jira-importer commentedon Jun 30, 2024
Ozgun OZ commented
A core extension is by definition something that we would like it to impact all plugins, or at least more than one.
So IMHO allowing plugins to define their own extensions is not the way to go. We can maybe consider the other way around. Giving extensions the ability to target specific plugins.
Via configurations maybe like defined in MNG-5897
Or just specify a new config file for plugins to allow their classloader be created by exporting specific apis from the core class-loader. Smth like the below
!image-2024-06-30-19-37-28-275.png!
jira-importer commentedon Jul 6, 2024
Ozgun OZ commented
Tamas Cservenak do you think it is feasible to export the Guice API from maven core by default ? Should I create a discussion thread in dev mailing list ? please let me know, I do not know if a Jira is the best place to discuss.
jira-importer commentedon Jul 6, 2024
Tamas Cservenak commented
gnodet FYI
Re exporting Guice from Maven Core by default: definitely not. This was hidden on purpose. Please create ML discussion about this.