Wednesday 15 September 2010

maven 3: Accessing version of "root" corporate POM -


Using Maven 3.0.4.

I have been assigned the task of providing corporate parent POM for our organization. My team will provide support for the development of questions or issues while using this POM. Often they will attach a build log to a support ticket. Therefore, I want my Corporate POM to co-ordinate Corporate Guardian's version with any build console. I am using the Enter plugin for this.

  & lt; GroupId> Org.apache.maven.plugins & lt; / GroupId> & Lt; ArtifactId & gt; Maven-antrun-plugin & lt; / ArtifactId> & Lt; Hanging & gt; & Lt; Execution & gt; & Lt; ID & gt; Echo construction environment & lt; / Id & gt; & Lt; Step & gt; Valid & lt; / Step & gt; & Lt; Goals & gt; & Lt; Goal & gt; Run & lt; / Target & gt; & Lt; / Targets & gt; & Lt; Configuration & gt; & Lt; Goal & gt; & Lt; Echo level = "info" message = "maven $ {maven.version}" function name = "version" /> & Lt; Echo level = "info" message = "corporate POMs $ {wish.the.version.here}" taskname = "version" /> .... & lt; / Target & gt;   

I do not know how many "levels" of POM heritage can come between the corporate parent and the POM used in the build.

  Corporate-originated team-basic application-parent child-module   

or as simple as: <<> Code $ $ {project.version} can not be resized / as the version of present (hair) project I can not use $ {project.parent.version} because I do not know how many legends I could have used hard code for corporate POM version of & lt; Corporate.pom.version & gt; Tried to define the asset, however, when I release my company POM, the release plugin does not know to update that property (which is understandable, it is not a dependency version, There is only one property, the release version can not know to update it).

Ideally, I want to be able to directly get a specific pom version directly, like a property, $ {some.groupId.corporate-parent.version} some. Is there anything like that?

If not, is a POM property being released with a releaseVersion during a release to release the project?

I can return the brute force on the way to manually edit the property before every release. My teammates did not appreciate this approach.

I hope that I do not have to write a custom plugin to do something that does not seem difficult at first glance.

I stopped using maven-antrun-plugin and its Switched instead I can get the necessary information with a simple POM hierarchy transcellal

  & lt; Plugin & gt; & Lt; Group & gt; Org.codehaus.gmaven & lt; / Group & gt; & Lt; ArtifactId & gt; Groovy-Maven-plugin & lt; / ArtifactId> & Lt; Version & gt; 2.0 & lt; / Edition & gt; & Lt; Hanging & gt; & Lt; Execution & gt; & Lt; ID & gt; Echo construction environment & lt; / Id & gt; & Lt; Step & gt; Valid & lt; / Step & gt; & Lt; Goals & gt; & Lt; Goal & gt; But execution & lt; / Target & gt; & Lt; / Targets & gt; & Lt; Configuration & gt; & Lt; Source & gt; & Lt ;! [CDATA [Def root pim = project; Whereas (rootPom.parent! = Null) {rootPom = rootPom.parent; } Project.properties.setProperty ('root.pom.version', rootPom.version); Log.info ("Maven Home:" + project.properties ['maven.home']); Log.info ("Java Home:" + project.properties ['java.home']); Log.info ("User Created:" + project.properties ['user.name']); Log.info ("Corp POM Version:" + Rootpam Edition); ]] & Gt; & Lt; / Source & gt; & Lt; / Configuration & gt; & Lt; / Execution & gt; & Lt; / Hanging & gt; & Lt; / Plugin & gt;   

project.properties.setProperty has stored the property calculated so that it can be accessed by the child's POMs.

The resulting log looks:

  [INFO] Maven home: c: \ dev \ maven \ apache-maven-3.0.4 [INFO] Java home: c: \ Program Files \ Java \ jdk1.7.0_13 \ jre [INFO] User-Created: user944849 [INFO] Corp POM Version: 0.26-SANAPSHOT    

No comments:

Post a Comment