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
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.
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.
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?
So, we could have different scopes without changing the POM model: "import-dependencies" (an alias to "import"), "import-plugins", "import-properties" and so on.
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.
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.
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.
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 .
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, ...) ?
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).
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 :
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.
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>
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...
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.
Activity
jira-importer commentedon Oct 8, 2014
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.
jira-importer commentedon Dec 15, 2015
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.
jira-importer commentedon Jun 24, 2016
Christian Schulte commented
There is no XML element
scopeavailable to pluginManagement/plugins.The only available elements are
groupId,artifactIdandversion.None of these can be -abused- to support some kind of import.
jira-importer commentedon Oct 15, 2016
Stephen Connolly commented
I think mix-ins is a more appropriate way to address this functional requirement
jira-importer commentedon Jan 30, 2017
Peter Palaga commented
Stephen Connolly are mixins planned or being worked on? Can I find out more about them somewhere?
jira-importer commentedon Mar 9, 2018
Deepak Abraham commented
Any chance this sees the light of day? This feature would be really useful...
jira-importer commentedon Jul 18, 2018
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.
jira-importer commentedon Jul 18, 2018
Robert Scholte commented
Requires at least pom model 5.0.0, because plugins don't have a scope
jira-importer commentedon Sep 6, 2018
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?
So, we could have different scopes without changing the POM model: "import-dependencies" (an alias to "import"), "import-plugins", "import-properties" and so on.
jira-importer commentedon Mar 8, 2019
jinyanan commented
It's a good feature which I need too.
jira-importer commentedon Aug 8, 2019
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.
jira-importer commentedon Nov 16, 2019
Miroslav Zaťko commented
I think it is must have feature
jira-importer commentedon Dec 6, 2019
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.
jira-importer commentedon Apr 22, 2020
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.
jira-importer commentedon May 5, 2020
Yannick Valot commented
I think there might be a problem because a BOM is at the same time :
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 .
1 remaining item
jira-importer commentedon Mar 7, 2021
Hervé Boutemy commented
jira-importer commentedon Apr 10, 2021
Hervé Boutemy commented
after some work with Andres Almiray on the topic, we managed to do a PoC containing
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:all,import:version, ...) ?jira-importer commentedon Apr 14, 2021
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).
jira-importer commentedon Apr 30, 2021
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?
jira-importer commentedon Nov 26, 2021
Andres Almiray commented
nightswimmings because we can't change the existing POM model (4.0.0) thus we must reuse an element such as
inheritedwhich 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
scopeelement.jira-importer commentedon Apr 2, 2022
Slawomir Jaranowski commented
We can have dependency for plugin also ... are theirs versions will be managed by import?
pluginManagment/plugins/plugin/dependenciesjira-importer commentedon May 2, 2022
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
dependencyManagementandpluginManagementmanaged 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 itmanagedor{}overrides{}, here's the idea:jira-importer commentedon Jun 14, 2022
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...
jira-importer commentedon Apr 6, 2023
Envious Guest commented
Hi guys,
is this feature even on a roadmap for 4.x? Or will it be most likely abandoned?
Thanks.
jira-importer commentedon Jun 28, 2023
Tamas Cservenak commented
PR doing it based on Dmitry Ovchinnikov original idea is here #1190
Thanks
jira-importer commentedon Jun 28, 2023
Tamas Cservenak commented
My responses to so far said proposals:
jira-importer commentedon Jul 17, 2023
Guillaume Nodet commented
MNG-7844 could help avoiding copy/pasting without going into mixins.