Maven include another pom for plugin configuration

后端 未结 2 945
独厮守ぢ
独厮守ぢ 2021-01-13 00:19

is there a way to include another pom or information in a maven pom ?

I have several poms which are basically not related or have different parent poms. Nevertheless

相关标签:
2条回答
  • 2021-01-13 00:53

    The only correct answer is to use inheritance. Have an inherited ancestor with this configuration in it. Since you have existing parent POMs, these must inherit from this new parent. If this isn't possible then rethink the hierarchy of your Maven projects, or else you'll have to copy and paste the same configuration into each file and add a comment indicating the section must not be modified / must be maintained consistently with [insert list of projects here].

    TLDR; Inheritance is designed specifically to resolve situations such as yours. If you can't use it then don't try to hack around it - either restructure your POMs or copy and paste!

    0 讨论(0)
  • 2021-01-13 01:16

    One way to do this is using pluginManagement section. plugin configurations can be defined in this section in a parent pom and will be available to inherited poms to be used as is or overridden.

    Here is the relevant maven documentation. In your specific case, you would need to organize your projects/poms suitably.

    0 讨论(0)
提交回复
热议问题