latest version

maven-buildmetadata-plugin

This Maven plugin generates build meta data and provides it as Maven build properties. The properties are written to a properties file that can be included in the generated artifact. The information can also be added to the manifest file.

The meta data includes

  1. SCM information
    • revision number
    • revision date
    • locally modified files
    • URL of SCM server
  2. build time
  3. operating system
    • name
    • architecture
    • version
  4. Java runtime
    • vendor
    • name
    • version
    • virtual machine
    • compiler
    • JAVA_OPTS
  5. Maven execution information
    • Maven version
    • active profiles
    • environment properties
    • command line and executed goals
    • MAVEN_OPTS
  6. build user
  7. build host name
  8. Artifact and version
    • group ID
    • artifact ID
    • build version
  9. project info
    • home page URL
    • categories
    • tags

For detailed information about the collected meta data and the properties that store them, please consult the listing of the build properties.

If your desired meta data is not included in the list, this is no show stopper! The Provider SPI allows you to add own implementations to provide additional meta data from any source and even export build information to remote systems.

Why add Meta Data to the Artifact?

Imagine the product is running on an application server. The product manager want to know,

  • which version of which artifact is currently running on that server?
  • which artifact maps to which source code version in the SCM repository?
  • what configuration set (including profiles and environment variables) has been used to generate the artifact?
  • on which machine was the artifact built?
  • when was the artifact built?

If you have no answers to these questions, but love to have, this tool is for you. It allows you to add this information easily as meta data to all kinds of Java archives.

The following sections show the artifacts provided by this plugin.

Properties File

The generated properties file is per default added to the META-INF folder of the archive and can be easily accessed at runtime. It contains the following information:

#Created by maven-buildmetadata-plugin.build.date=17.07.2010 19\:13\:00
build.copyright.year=2008-2010
build.date.pattern=dd.MM.yyyy HH\:mm\:ss
build.timestamp.millis=1279386780654
build.year=2010

build.version=0.7.0
build.version.full=0.7.0-20100717r4223

build.host.name=DevBox001
build.user=john.doe

build.maven.execution.cmdline=clean package
build.maven.execution.goals=clean, package
build.maven.execution.isRoot=true
build.maven.execution.opts=-Xmx2048M -XX\:MaxPermSize\=256m
build.maven.execution.profile.active.basic=settings.xml
build.maven.execution.profile.active.nexus=settings.xml
build.maven.execution.profiles.active=nexus, basic
build.maven.version=2.2.1

build.scmLocallyModified=false
build.scmRevision.date=16.07.2010 18\:12\:57
build.scmRevision.id=4223
build.scmRevision.url=scm\:svn\:https\://smartics.info/svn/smartics/maven/maven-buildmetadata-plugin/trunk

Manifest File

The generated information can be used in the Manifest file, using the maven-jar-plugin.

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven

Build-Jdk: 1.6.0_20
Built-By: john.doe
Built-OS: Windows 7 / amd64 / 6.1
Built-Host: DevBox001
Java-Vendor: Sun Microsystems Inc.
Java-Version: 1.6.0_20
Maven-Version: 2.2.1

Specification-Vendor: smartics
Specification-Title: maven-buildmetadata-plugin
Specification-Version: 0.7.0

Implementation-Vendor: smartics
Implementation-Vendor-Id: de.smartics.maven.plugin
Implementation-Title: maven-buildmetadata-plugin
Implementation-Version: 0.7.0
Implementation-URL: http://project.smartics.de/public/de.smartics.mave
 n.plugin/maven-buildmetadata-plugin/0.7.0

Implementation-Date: 17.07.2010 19:13:00
Implementation-DatePattern: dd.MM.yyyy HH:mm:ss
Implementation-Timestamp: 1279386780654

Implementation-Full-Version: 0.7.0-20100717r4223

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

The information is not added automatically, but requires to be edited manually. Please refer to Use with JAR plugin for details.

Please note that other archive type can be configured similarly with e.g. the maven-ear-plugin or maven-war-plugin.

Report

To map a site documentation to an artifact (and vice versa), a build report can be integrated into the site documentation. This report contains build information like the revision and revision date.

The Build Report of this project may serve as an example.

Getting Started

Please have a look at the sample usage patterns.

The buildmetadata:provide-buildmetadata documentation details the configuration options.