UberPom

Merging pom hierarchy parameters

License

License

Categories

Categories

ORM Data
GroupId

GroupId

com.igormaznitsa
ArtifactId

ArtifactId

uber-pom
Last Version

Last Version

1.0.3
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

UberPom
Merging pom hierarchy parameters
Project URL

Project URL

https://github.com/raydac/uber-pom
Project Organization

Project Organization

Igor Maznitsa
Source Code Management

Source Code Management

https://github.com/raydac/uber-pom

Download uber-pom

How to add to project

<plugin>
    <groupId>com.igormaznitsa</groupId>
    <artifactId>uber-pom</artifactId>
    <version>1.0.3</version>
</plugin>

Dependencies

compile (2)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.4
commons-io : commons-io jar 2.4

provided (3)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 3.0
org.apache.maven : maven-core jar 3.0
org.apache.maven : maven-artifact jar 3.0

test (4)

Group / Artifact Type Version
org.apache.maven.plugin-testing : maven-plugin-testing-harness jar 2.1
org.apache.maven : maven-compat jar 3.0
org.apache.maven.shared : maven-verifier jar 1.5
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

License Apache 2.0 Java 6.0+ Maven central Maven 3.0.3+ PayPal donation Yandex.Money donation

Introduction

Sometime I develop and publish maven plugins in maven central. The Most comfortable way to organize maven plugin testing is to make a pom module hierarchy because maven keeps module build in defined order, also it allows to share common options between modules. But in the case there is some issue, all child modules have link to their parent and the parent must be published also together with children. So I developed the uber-pom plugin to make some around way.

Changelog

1.0.3 (31-jul-2019)

  • refactoring

1.0.2 (04-apr-2019)

  • added removeDependencies with wildcard support

1.0.1 (17-apr-2016)

  • issue #3, added flag removeSiblingDuplications to find sibling duplications in the result uber pom XML and removing them. By default it is turned off.
  • issue #2, added support for system property 'upom.delete.on.exit' to override value of 'deleteOnExit' parameter

1.0

  • Initial version

How it works?

The Plugin just merging all pom.xml in project module hierarchy (or only defined depth of the hierarchy) and saves the generated uber-pom into defined place, then it saves link to the file into the current maven project model. It works on the INITIALIZE phase. So the result packed artifact will have the uber-pom packed into the result archive.

May be there is official solution?

May be yes, I have found pre-released maven-flatten which may be doing the same business but I prefer my own solutions.

How to use?

Add the plugin in pom.xml

Just add the plugin into pom.xml of the project which needs uber-pom

  <build>
    <plugins>
    ...
      <plugin>
        <groupId>com.igormaznitsa</groupId>
        <artifactId>uber-pom</artifactId>
        <version>1.0.3</version>
        <configuration>
          <remove>
            <section>parent</section>
            <section>modules</section>
            <section>profiles/profile/modules</section>
          </remove>
          <removeSiblingDuplications>true</removeSiblingDuplications>
          <removeDependencies>
            <dependency>
              <scope>test</scope>
              <systemPath>*</systemPath>
            </dependency>
          </removeDependencies>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>upom</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    ...
    </plugins>
  </build>

NB! By default the plugin just merging pom models in hierarchy, so you should add <remove> section to remove the 'parent' and 'modules' from the result uber-pom. I don't make that automaticaly to keep universality.

I want to remove some sections in the result

Just add list of paths to the sections into <configuration><remove> and the sections will be removed from the result.

  <configuration>
    <remove>
      <section>developers</section>
      <section>build/plugins</section>
      <section>developers/developer/email</section>
    </remove>
  </configuration>

I want keep some sections unchanged!

Add paths to such sections into <configuration><keep>

  <configuration>
    <keep>
      <section>developers</section>
      <section>description</section>
    </keep>
  </configuration>

The Sections in the result will be the same as in the original project pom.xml.

How to change value of some pom parameters?

Sometime it is good to change some record in the pom.xml, the plugin allows to do that

<configuration>
 <set>
    <property>
      <name>description</name>
      <value>It is new description of the pom.xml</value>
    </property>
    <property>
      <name>developers/developer/email</name>
      <value>[email protected]</value>
    </property>
  </set>
</configuration>

How to save uber-pom in another place?

The Generated uber-pom by default will be placed in the same folder where the project pom is. You can change that through <folder> setting.

<configuration>
  <folder>/anotherFolderToSaveUberPom</folder>
</configuration>

I wanna change the result uber-pom name

By default the uber-pom has name uber-pom.xml but sometime it is needed to be changed, it is possible through <name> setting.

<configuration>
  <name>customUberPom.xml</name>
</configuration>

I can't find uber-pom after session

By default the generated and saved uber-pom will be removed after session. If you want to keep the file then disable its deleting with flag <deleteOnExit>

<configuration>
  <deleteOnExit>false</deleteOnExit>
</configuration>

How to merge only restricted number of hierarchy levels?

By default the plugin merges all hierarchy levels, but you can restrict the number through the <depth> parameter

<configuration>
  <depth>2</depth>
</configuration>

In the example, only two upper levels will be involved into merging.

Versions

Version
1.0.3
1.0.2
1.0.1
1.0.0