resolved-pom-maven-plugin
What
Install with
<plugin>
<groupId>io.paradoxical</groupId>
<artifactId>resolved-pom-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<properties>
<revision>${revision}</revision>
</properties>
</configuration>
<executions>
<execution>
<id>resolve-my-pom</id>
<phase>initialize</phase>
<goals>
<goal>resolve-pom</goal>
</goals>
</execution>
</executions>
</plugin>
Why
If you ever wanted to auto version your artifacts, you may have found this article describing what appears to be a simple way of doing so.
The problem comes when you try it, ${revision}
doesn't get replaced in the distributed pom files (the ones up on maven central.) This causes huge issues with maven transitive dependency resolution. There was a fix posted a while ago to address some of the problems However this solution doesn't address when you need to GPG sign your artifacts (like you do to relase to maven central.)
With this plugin, you can use the ${revision}
style versioning and still easily deploy to maven central
Other plugins
After this project was built I found another plugin that does the basically same thing (and in some ways was better!)
The only difference is that it replaces every property in the pom with it's filtered versions where as this plugin uses a white-listed approach.
Maven Internals
I spent a good amount of time looking through maven plugins and internals to figure out the easiest way to trick maven into doing what I want :)
Here is some of the resources i used:
Internals
- Filtering: Understanding what filtering is doing
Plugins
- Resources: useful as a how to do filtering reference
- Install: this is where poms are installed by default, also useful for the stupid lastModified check they do on files
- Gpg:Sign: Useful to figure out what order signatures are added
- Nexus:Deploy: If you want to understand that crazy that is the nexus deploy plugin
Misc
- Nexus staging plugin options: https://github.com/sonatype/nexus-maven-plugins/tree/master/staging/maven-plugin
- Maven plugin execution order: http://www.mkyong.com/maven/maven-plugin-execution-order-in-same-phase/
- Plexus utils: the deep dark stuff of maven. https://github.com/codehaus-plexus/plexus-utils/blob/master/src/main/java/org/codehaus/plexus/util/FileUtils.java