The build metadata maven plugin creates a detailed report of the various build time parameters employed during a build. The information includes useful data that can be used to provide better transparency and accountability of the build process. Meta data includes build times and dates, user environment information and Java/Maven command line options. The reporting is configurable and extensible as well as being adaptable for projects using multiple artifacts.
You can access the binary artifact via Maven Central or the JBoss releases repository.
JBoss Releases:
SCM information
- revision number
- revision date
- locally modified files
- URL of SCM server
System information
- build time
- operating system
- name
- architecture
- version
Java runtime
- vendor
- name
- version
- virtual machine
- compiler
- JAVA_OPTS
Maven execution information
- Maven version
- 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
The following specifies the minimum requirements to run this Maven plugin:
- Maven 2.0
- JDK 1.5
Clone the repository to your workspace and build with maven:
git clone https://github.com/release-engineering/buildmetadata-maven-plugin.git
mvn install
- Edit your project pom.xml to include the following:
The options in the plugin's configuration section will produce a report that will include the command line executed along with the Maven and Java Options. For the full options available and details on how to extend functionality please refer to the upstream documentation linked below.
<project>
...
<!-- Set up the repository to fetch the buildmetadata-maven-plugin from -->
<repositories>
<repository>
<id>repository.jboss.org</id>
<name>JBoss Releases</name>
<url>http://repository.jboss.org/nexus/content/repositories/releases/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repository.jboss.org</id>
<name>JBoss Releases</name>
<url>http://repository.jboss.org/nexus/content/repositories/releases/</url>
</pluginRepository>
</pluginRepositories>
<!-- Declare the dependancy on the buildmetadata-maven-plugin -->
<dependencies>
<dependency>
<groupId>com.redhat.rcm.maven.plugin</groupId>
<artifactId>buildmetadata-maven-plugin</artifactId>
<version>1.3.1</version>
</dependency>
</dependencies>
<!-- Configure the buildmetadata-maven-plugin with the required reporting options -->
<build>
<plugins>
<plugin>
<groupId>com.redhat.rcm.maven.plugin</groupId>
<artifactId>buildmetadata-maven-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>provide-buildmetadata</goal>
</goals>
<configuration>
<createPropertiesReport>false</createPropertiesReport>
<xmlOutputFile>${project.build.outputDirectory}/META-INF/buildmetadata.xml</xmlOutputFile>
<hideCommandLineInfo>false</hideCommandLineInfo>
<hideMavenOptsInfo>false</hideMavenOptsInfo>
<hideJavaOptsInfo>false</hideJavaOptsInfo>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>
If you want to execute the plugin from the command line with no modifications to your pom file the following example can be used:
mvn clean install -X -C -B dependency:resolve-plugins \
-Dmaven.test.skip=true \
-Dbuildmetadata:provide-buildmetadata \
-Dbuildmetadata:createPropertiesReport=false \
-Dbuildmetadata:xmlOutputFile={project.build.outputDirectory}/META-INF/buildmetadata.xml \
-Dbuildmetadata:hideCommandLineInfo=false \
-Dbuildmetadata:hideMavenOptsInfo=false \
-Dbuildmetadata:hideJavaOptsInfo=false \
-Dbuildmetadata:addScminfo=true | tee build.log
Assuming the plugin configuration in your projects pom.xml matches the example provided then simply executing maven withthe install goal will create a buildmetadata.xml file in the generated jar file under the META-INF direcory of the archive.
mvn install
You can view the generated build.properties file in the archive without extracting it with the following command:
unzip -p example/MyApp/target/MyApp-1.0-SNAPSHOT.jar META-INF/buildmetadata.xml
The report will resemble the example below:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<buildmetadata xmlns="http://github.com/sbadakhc/buildmetadata-maven-plugin" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://github.com/sbadakhc/buildmetadata-maven-plugin http://github.com/sbadakhc/buildmetadata-maven-plugin">
<name>1.0-20131105-SNAPSHOT</name>
<version>1.0-SNAPSHOT</version>
<groupId>com.redhat.rcm</groupId>
<artifactId>HelloWorld</artifactId>
<date>2013-11-05T08:57:22</date>
<timestamp>1383638242882</timestamp>
<build-year>2013</build-year>
<project>
<copyright-year>null-2013</copyright-year>
</project>
<scm>
<revision>42c32d5c55a9fe7a0ec08ccf7719273fa268eadf</revision>
<revision-date>2014-02-09T00:00:00</revision-date>
<url>scm:git:git@github.com:sbadakhc/HelloWorld.git</url>
</scm>
<runtime>
<build-server>localhost.localdomain</build-server>
<build-user>sbadakhc</build-user>
<os>
<arch>amd64</arch>
<name>Linux</name>
<version>3.11.6-200.fc19.x86_64</version>
</os>
<java>
<name>OpenJDK Runtime Environment</name>
<version>1.7.0_45-mockbuild_2013_10_16_17_47-b00</version>
<vendor>Oracle Corporation</vendor>
<vm>OpenJDK 64-Bit Server VM</vm>
<compiler>HotSpot 64-Bit Tiered Compilers</compiler>
</java>
<maven>
<version>3.0.5</version>
<commandline>-X -e install</commandline>
<execution-project>com.redhat.rcm:HelloWorld:jar:1.0-SNAPSHOT</execution-project>
<is-excution-root>true</is-excution-root>
<goals>
<goal>install</goal>
</goals>
<options>-Xmx4096m -XX:MaxPermSize=2048m -Xnoclassgc -XX:+DisableExplicitGC</options>
</maven>
</runtime>
<misc>
<metadata name="build.date.pattern">dd.MM.yyyy HH:mm:ss</metadata>
</misc>
</buildmetadata>
The following goals are supported. For a full explanation please refer to the upstream providers documentation.
- buildmetadata:build-point
- buildmetadata:buildmetadata-report
- buildmetadata:provide-buildmetadata
This project is a fork of http://www.smartics.eu/buildmetadata-maven-plugin
At the time of forking the project the buildmetadata-maven-plugin had not been deployed to Central. However since version 1.6.1 the upstream is now available in Central (See: https://github.com/smartics/buildmetadata-maven-plugin and https://repo1.maven.org/maven2/de/smartics/maven/plugin/buildmetadata-maven-plugin/ )