Maven include another pom for plugin configuration

陌路散爱 提交于 2019-12-01 02:09:17

问题


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 for packaging it is required to have a Manifest identical to all projects.

So currently I have in a pom:

<plugin>
  <artifactId>maven-assembly-plugin>
   <!--- .... -->
    <archive>
      <manifestEntries>
        <build-date>....</build-date>
        <build-nr>.....</build-nr>

etc etc

I would like to avoid to paste this configuration to all severall poms.

So how can I share the configuration of a plugin without inheritance ?

Thanks


回答1:


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.




回答2:


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!



来源:https://stackoverflow.com/questions/5729437/maven-include-another-pom-for-plugin-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!