Using Maven 3.0.4.
I am tasked with providing a corporate parent POM for our organization. My team will provide support for questions or issues developers have when using this POM. Often they will attach a build log to a support ticket. So, I want my corporate POM to echo the version of the corporate parent to the console with any build. I'm using the antrun plugin for this.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>echo-build-environment</id>
<phase>validate</phase>
<goals><goal>run</goal></goals>
<configuration>
<target>
<echo level="info" message="Maven ${maven.version}" taskname="Version" />
<echo level="info" message="Corporate POMs ${want.the.version.here}" taskname="Version" />
....
</target>
Trick is, I have no idea how many "levels" of POM inheritance may come between the corporate parent and the POM used in the build. We could have an inheritance structure something like this:
corporate-parent
team-parent
application-parent
child-module
Or as simple as this:
corporate-parent
a-simple-library
I cannot echo ${project.version}
as that will be the version of the current (child) project. I cannot use ${project.parent.version}
because I have no idea how many levels of inheritance there might be. I tried defining a <corporate.pom.version>
property, hardcoded to the corporate POM version, however when I release my corporate POM the release plugin doesn't know to update that property (which makes sense, it's not a dependency version, it's just a property, the release version can't know to update it).
Ideally, I'd love to be able to get the version of a specific POM directly through a property, something like ${some.groupId.corporate-parent.version}
. Does anything like that exist?
If not, is there a way during a release to update a POM property with the releaseVersion
of the project being released?
I could revert to the brute force way of manually editing the property before each release. My teammates wouldn't appreciate that approach.
I'm hoping I don't have to write a custom plugin to do something that at first glance didn't seem to be difficult.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…