Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven include another pom for plugin configuration

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

like image 208
Emerson Avatar asked Apr 20 '11 11:04

Emerson


2 Answers

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.

like image 191
Raghuram Avatar answered Oct 13 '22 01:10

Raghuram


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!

like image 29
KomodoDave Avatar answered Oct 13 '22 01:10

KomodoDave