Skip to content

[MNG-5588] Scope import in pluginManagement #6471

Open

Description

@jira-importer

Romain N opened MNG-5588 and commented

I can do this in dependencyManagement to define dependencies versions:

<dependencyManagement>
  <dependency>
    <groupId>test</groupId>
    <artifactId>test</artifactId>
    <version>1</version>
    <scope>import</scope>
    <type>pom</type>
  </dependency>
</dependencyManagement>

It could be great to can do the same things in pluginManagement to define version plugin and default behavior.


Affects: 3.1.1

Issue Links:

  • MNG-6562 WARN if plugins injected by default lifecycle bindings don't have their version locked in pom.xml or parent

  • MNG-5102 Mixin POM fragments

  • MNG-3220 Allow managed dependencies to be imported into other projects

  • MNG-7844 Support for DTD entities and XInclude in the code at build time

Remote Links:

84 votes, 103 watchers

Activity

  1. jira-importer commented on Oct 8, 2014

    @jira-importer
    Author

    F Carlsen commented

    This would be great improvement and would helps share plugin configuration and standards across projects.

    At the moment, the only way of sharing plugin configuration is through inheritance. Unfortunately, this isn't always feasible, and relying on inheritance for sharing configuration that only some children are going to need is a bad practice (e.g. violates Liskov's substition principle). Composition would be better than Inheritance for configuration anyway.

    In a multi-module project, you will get a warning if you're trying to use parent pom's from different inheritance hierarchies, which says it may be disallowed in a future release, so there's really no decent alternatives today and I hope this feature gets prioritized.

  2. jira-importer commented on Dec 15, 2015

    @jira-importer
    Author

    Christian Roeder commented

    Such a functionality would really be practial if you're stuck with Maven and can not do composition as it is possible with gradle.

  3. jira-importer commented on Jun 24, 2016

    @jira-importer
    Author

    Christian Schulte commented

    There is no XML element scope available to pluginManagement/plugins.

    The only available elements are groupId, artifactId and version.
    None of these can be -abused- to support some kind of import.

  4. jira-importer commented on Oct 15, 2016

    @jira-importer
    Author

    Stephen Connolly commented

    I think mix-ins is a more appropriate way to address this functional requirement

  5. jira-importer commented on Jan 30, 2017

    @jira-importer
    Author

    Peter Palaga commented

    Stephen Connolly are mixins planned or being worked on? Can I find out more about them somewhere?

  6. jira-importer commented on Mar 9, 2018

    @jira-importer
    Author

    Deepak Abraham commented

    Any chance this sees the light of day? This feature would be really useful...

  7. jira-importer commented on Jul 18, 2018

    @jira-importer
    Author

    Jeff Thomas commented

    I would also love to see this feature.

    I just implemented a 'dependencyManagement' import POM for all of the Axis2 dependencies that we need to keep synchronized over multiple projects without parent-inheritence.

    However, Axis2 also provides several Maven Plugins which I would like to centrally manage the versions and base-configurations for as well.

    The Mixin plugin still requires you to define plugin versions in the parent-poms...ideally I would want to do that centrally as with the dependencyManagement import POM.

  8. jira-importer commented on Jul 18, 2018

    @jira-importer
    Author

    Robert Scholte commented

    Requires at least pom model 5.0.0, because plugins don't have a scope

  9. jira-importer commented on Sep 6, 2018

    @jira-importer
    Author

    Dmitry Ovchinnikov commented

    The dependency version importing is a killer feature of Maven, it's a "declarative way" the Maven belongs to. It would be very useful to have something like that for plugins. Could it be like that?

    <dependencyManagement>
      <dependency>
         <groupId>some-group-id</groupId>
         <artifactId>some-artifact-id</artifactId>
         <version>a-version</version>
         <scope>import-plugins</scope>
         <type>pom</type>
      </dependency>
    </dependencyManagement>

    So, we could have different scopes without changing the POM model: "import-dependencies" (an alias to "import"), "import-plugins", "import-properties" and so on.

  10. jira-importer commented on Mar 8, 2019

    @jira-importer
    Author

    jinyanan commented

    It's a good feature which I need too.

  11. jira-importer commented on Aug 8, 2019

    @jira-importer
    Author

    Matthew Ouyang commented

    Dmitry Ovchinnikov I would argue that both a new scope and MNG-5102 are unnecessary for this ticket.  If you're importing a pom then you import the whole thing, not just the dependencyManagement portion.  Maybe whatever part of the code that parses the pom and sets up dependencyManagement can be augmented to set up in pluginManagement as well.

  12. jira-importer commented on Nov 16, 2019

    @jira-importer
    Author

    Miroslav Zaťko commented

    I think it is must have feature

  13. jira-importer commented on Dec 6, 2019

    @jira-importer
    Author

    Thomas Repnik commented

    Can't believe such an import task is open since more than 5 years. If just one complex plugin configuration should be shared, maven enforces pom inheritance. This is a big design flaw.

  14. jira-importer commented on Apr 22, 2020

    @jira-importer
    Author

    Christophe Domas commented

    It would be very useful for spring-boot project. A lot of stuff is done in the parent pom of spring boot. If you want to import your own parent pom, you can use the spring boot bom for dependencies but you'll have to redefine the plugin management section.

  15. jira-importer commented on May 5, 2020

    @jira-importer
    Author

    Yannick Valot commented

    I think there might be a problem because a BOM is at the same time :

    • The deliverable artefact
    • The description of how to build and deliver the artefact itself

    I have several projects where I need to specify an explicit version for maven-deploy-plugin, which I usually do through pluginManagement.

    These projects provide, among other artefacts, a BOM to be imported by other projects.

    It seems my BOMs (which have no parent) needs the pluginManagement in order to deploy themselves, but I do not wish projects importing my bom to be affected by this.

    Maybe this particular case has another solution (maybe I would only need to specify the plugin directive and not the pluginManagement). Still we need to be careful to clearly limit what is imported from a BOM .

  16. 1 remaining item

  17. jira-importer commented on Mar 7, 2021

    @jira-importer
    Author

    Hervé Boutemy commented

    There is no XML element scope available to pluginManagement/plugins
    perhaps we can (ab)use the "inherited" element of pluginManagement/plugins: https://maven.apache.org/ref/3.6.3/maven-model/maven.html#class_plugin

  18. jira-importer commented on Apr 10, 2021

    @jira-importer
    Author

    Hervé Boutemy commented

    after some work with Andres Almiray on the topic, we managed to do a PoC containing

    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.its.mng5588</groupId>
                <artifactId>plugins-bom</artifactId>
                <version>0.1</version>
                <inherited>import</inherited>
            </plugin>
        </plugins>
    </pluginManagement>

    it's only a PoC, quickly coded, but it already gave us a good experience to add one new question: given a plugin not only defines a version, but also a config and executions (see full plugin XML definition), what should we do:

    • import pluginManagement version only?
    • import everything?
    • create multiple types of import (like import:all, import:version, ...) ?
  19. jira-importer commented on Apr 14, 2021

    @jira-importer
    Author

    Romain Manni-Bucau commented

    Hi Hervé Boutemy, is it possible to make inherited (in plugin) an object with includes/excludes ("à la maven shade plugin") to force the transitiveness to only whitelisted/blacklisted plugins otherwise it breaks too easily plugins.

    The very important point here is to see that dependencies are a flat classpath at each stage but plugin dependencies don't exist and are per plugin so import should be per plugin as well (even if wildcards/patterns are tolerated for easyness).

    About the import I thought that dependencyManagement would be imported as well but for plugin and that the plugin-bom would ignore plugin* sections to keep it consistent and unsurprising. The option to import pluginManagemenent of the bom has several pitfalls like not enabling to override a dependency in undeclared plugins (thinking to force jackson N+1 globally for ex).

  20. jira-importer commented on Apr 30, 2021

    @jira-importer
    Author

    nightswimmings commented

    I would make it just behave like DependencyManagement bom for coherence. PluginManagement has configurations and executions, but depenencyManagement has its own particularities as well, like excludes/includes. And it uses the syntax :

    <type>pom</type>
    <scope>import</scope>

    Why not behaving equally?

     

  21. jira-importer commented on Nov 26, 2021

    @jira-importer
    Author

    Andres Almiray commented

    nightswimmings because we can't change the existing POM model (4.0.0) thus we must reuse an element such as inherited which so happens to accept a String at the moment.

    In future versions of the Model (5.0.0) we may review this decision and add a proper scope element.

  22. jira-importer commented on Apr 2, 2022

    @jira-importer
    Author

    Slawomir Jaranowski commented

    We can have dependency for plugin also ... are theirs versions will be managed by import?

    pluginManagment/plugins/plugin/dependencies

  23. jira-importer commented on May 2, 2022

    @jira-importer
    Author

    ryenus commented

    I'd like to share one idea I have, instead of having separate imports for dependencies and plugins, maybe just combine the two into one?

    Given that we are already used to having dependencyManagement and pluginManagement managed in one bom, like in spring-boot-dependencies, then we have to come up with a common parent xml element for both managed dependencies and managed plugins. Be it managed or {}overrides{}, here's the idea:

    <project>
       ...
       <dependencies>...</dependencies>
       <plugins>...</plugins>
       ...
    
       <overrides>
          <!-- imported overrides, carrying both dependencies and plugins -->
          <imports>
             <import>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <type>bom</type>
             </import>
          </imports>
    
          <!-- local dependencies overrides -->
          <dependencies>...</dependencies>
    
          <!-- local plugins overrides -->
          <plugins>...</plugins>
       </overrides>
    
    </project>
  24. jira-importer commented on Jun 14, 2022

    @jira-importer
    Author

    Ivo Lopes commented

    Hervé Boutemy and Andres Almiray, your solution seems great to me... a perfect solution would enable me to override the plugin's config but otherwise use the ones specified in the imported pom...

  25. jira-importer commented on Apr 6, 2023

    @jira-importer
    Author

    Envious Guest commented

    Hi guys,

    is this feature even on a roadmap for 4.x? Or will it be most likely abandoned?

    Thanks.

  26. jira-importer commented on Jun 28, 2023

    @jira-importer
    Author

    Tamas Cservenak commented

    PR doing it based on Dmitry Ovchinnikov original idea is here #1190
    Thanks

  27. jira-importer commented on Jun 28, 2023

    @jira-importer
    Author

    Tamas Cservenak commented

    My responses to so far said proposals:

    • Mixins are sadly nowhere.
    • Plugins should not have a scope (nor have a type).
    • Not adding new scope "import-plugins" but bolting onto existing "import" MAY potentially break existing builds (but I do not oppose to try it out maybe).
    • Abuse of "inherited=import" field is not nice nor is intuitive.
  28. jira-importer commented on Jul 17, 2023

    @jira-importer
    Author

    Guillaume Nodet commented

    MNG-7844 could help avoiding copy/pasting without going into mixins.

  29. added
    priority:major
    on Jul 6, 2025
  30. modified the milestones: , 4.x 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

    priority:major

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions