Skip to content

[MNG-7921] Allow plugins to control classpath extensions #8997

Open

Description

@jira-importer

Dave Syer opened MNG-7921 and commented

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.


Affects: 3.9.5

Attachments:

Issue Links:

  • MNG-7955 Plugins should be allowed some control over the imported packages

Activity

  1. jira-importer commented on Jun 30, 2024

    @jira-importer
    Author

    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.

    1. 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.
    2. 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:

    1. Exposing the Guice API by default. But this must be extensively tested to be sure we do not break something existing.
    2. 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).
  2. jira-importer commented on Jun 30, 2024

    @jira-importer
    Author

    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!

  3. jira-importer commented on Jul 6, 2024

    @jira-importer
    Author

    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.

  4. jira-importer commented on Jul 6, 2024

    @jira-importer
    Author

    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.

  5. added
    enhancement
    priority:major
    on Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpriority:major

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions