I have maven plugins under development and some of them are published in maven central. Usually each plugin is developed in bounds of some maven project tree wich more or less complex structure but such structure not needed for artifact publishing. To get plain version of pom.xml with only needed fields, I have developed the plug-in and it works well for my purposes. I have published it in the maven central and hope it will be useful for someone else.
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
The plugin just merging all pom.xml in project module tree hierarchy (or only required depth of the hierarchy tree) and saves the created uber-pom into required place. The new generated pom file path provided into the current active maven project model. It during INITIALIZE phase and the result packed artifact will have the uber-pom packed in the result artifact.
I have found flatten-maven-plugin, it also allows to make similar business but it works not very well in pair with maven-shade-plugin and it is critically for me.
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.
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>
Add paths to such sections into <keep>
property
<configuration>
<keep>
<section>developers</section>
<section>description</section>
</keep>
</configuration>
those secttions in the result will be the same as in the original project pom.xml.
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>
Generated uber-pom by default will be placed in the same folder where the project pom is. You can change that through <folder>
property.
<configuration>
<folder>/anotherFolderToSaveUberPom</folder>
</configuration>
By default the uber-pom named as uber-pom.xml
but sometime should be changed, it is possible through <name>
property.
<configuration>
<name>customUberPom.xml</name>
</configuration>
By default the generated uber-pom will be removed after session. If you want to keep the file then disable delete action with flag <deleteOnExit>
<configuration>
<deleteOnExit>false</deleteOnExit>
</configuration>
By default the plugin merges all hierarchy levels till the root, but you can restrict the number with the <depth>
property
<configuration>
<depth>2</depth>
</configuration>
In the example, only two upper tree levels will be involved into build of merging result.