Blog




If you pass SNAPSHOT versions of your software around, it is sometimes difficult to derive the source code version from the artifact. Usually you should produce releases (maybe alpha or beta releases), so that that the source code is tagged in your SCM. But sometimes this does, for whatever reason, not work. In these cases it would be nice, if the SCM revision number would be written to the JAR manifest automatically. This would make fiddling out the source code for a given artifact a brise.

The Buildmetadata Maven Plugin (previously called Maven Buildmetadata Plugin, but renamed due to the naming convention of the Maven team that all plugins following the naming scheme maven-xyz-plugin are developed by the them) does exactly that. If your are building JAR/EAR/WAR files with Maven the plugin fetches the version number from an SVN server (currently the only supported SCM system) and writes it to the manifest file.

Implementation-SCM-Revision-Date: 16.07.2010 18:12:57
Implementation-SCM-Revision-Number: 4223

The build.properties file, also stored in the META-INF folder, reveals this and additional information:

build.scmLocallyModified=false
build.scmRevision.date=26.08.2012 12\:10\:03
build.scmRevision.id=4223
build.scmRevision.url=scm\:svn\:https\://server/svn/product/trunk

The plugin checks, if the build uses locally modified (build.scmLocallyModified) files. If there a locally modified files, which usually indicates that the build was made on a developer station, these files are listed by their names.

This makes the task of tracking the source code by examining a binary artifact an instant success.

The buildmetadata-plugin also collects additional information like the machine the artifact has been built on, together with the operating system, Java and Maven version. Any environment information can be added to the meta data of the generated artifact. The plugin also supports a simple hook to access further information from a remote system.

As an add-on there is a report plugin that displays the build information on your Maven site. Look at the plugin's build report for an example.

So if you are looking for a tool to add information to the meta data of your artifacts, the chances are good that the Buildmetadata Maven Plugin will help you with your task.


Link

Link

Posts