Page tree

 

 

 

Generates build metadata 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.

 

Search

 

Red Hat Fork

There is a fork of the Buildmetadata Maven Plugin supported by a team at Red Hat.

The fork is also available as a GitHub project and their artifact is deployed to the public Maven Repository!

We are continuing with supporting our version, adding new features, and keeping close contact with the team at Red Hat. For more information please read Great News: Buildmetadata Maven Plugin forked!


More on documentation?

This project is documented with projectdoc. projectdoc is available for Confluence.

More smartics Plugins

Plugins for Maven

The query matched no documents.

version 1.6.1

Introduction

This Maven plugin generates build metadata 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 in an XML format or to the manifest file.

The metadata includes

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

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

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

Why add Metadata 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 metadata 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 buildmetadata-maven-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/buildmetadata-maven-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: buildmetadata-maven-plugin
Specification-Version: 0.7.0

Implementation-Vendor: smartics
Implementation-Vendor-Id: de.smartics.maven.plugin
Implementation-Title: buildmetadata-maven-plugin
Implementation-Version: 0.7.0
Implementation-URL: http://project.smartics.de/public/de.smartics.mave
 n.plugin/buildmetadata-maven-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.

One Word of Warning

Build metadata may contain sensitive information you do not want to expose. If you include the commandline to document how the build has been started using

-DbuildMetaData.hideCommandLineInfo=false -Ppassword=verySecret

This line will be part of the report!

Please also note that the commandline contains the information as digested by Maven. Any variable replacements or using the alias-maven-plugin as in

p -DbuildMetaData.hideCommandLineInfo=false

(for those who do not know this plugin: p is an alias for -T 4 clean package) does not mask the commandline:

<commandline>-T 4 clean package -DbuildMetaData.hideCommandLineInfo=false</commandline>

We tried to make the default configuration very restrictive. But nonetheless we advice you to double check the build metadata you include into your artifacts. Especially if these artifacts are published to anonymous third parties.

Getting Started

Please have a look at the sample usage patterns.

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

Project Blog

The following posts provide more information about this plugin on our blog.

Blog Posts

This page has no comments.