Versioning Maven Plugin

Generates a source code file with information from your SCM. This makes it easy to show this information inside your application.

License

License

Categories

Categories

Maven Build Tools Net
GroupId

GroupId

net.tietema.versioning
ArtifactId

ArtifactId

versioning-maven-plugin
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

Versioning Maven Plugin
Generates a source code file with information from your SCM. This makes it easy to show this information inside your application.
Project URL

Project URL

http://github.com/jtietema/versioning-maven-plugin
Source Code Management

Source Code Management

https://github.com/jtietema/versioning-maven-plugin

Download versioning-maven-plugin

How to add to project

<plugin>
    <groupId>net.tietema.versioning</groupId>
    <artifactId>versioning-maven-plugin</artifactId>
    <version>1.0</version>
</plugin>

Dependencies

compile (5)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 2.0
org.codehaus.plexus : plexus-utils jar 3.0.8
org.eclipse.jgit : org.eclipse.jgit jar 2.3.1.201302201838-r
com.squareup : javawriter jar 1.0.4
org.apache.maven : maven-project jar 2.0.9

provided (1)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.2

test (1)

Group / Artifact Type Version
junit : junit jar 4.8.2

Project Modules

There are no modules declared in this project.

Versioning maven plugin

A Maven plugin that generates a small Java file with some revision info from git. This plugin makes it easy to show info from your git repository inside your app. This makes it possible to trace a build back to the exact revision and state the repository was in when the build was made.

An example of the output:

public final class Version {
  public static final String BRANCH = "master";
  public static final String REVISION = "2f6422230fc18cb427eeb9f6201e83db3adb0f24";
  public static final String REVISION_SHORT = "2f642223";
  /**
   * Strict Clean means no changes, not even untracked files
   */
  public static final boolean STRICT_CLEAN = false;
  /**
   * Lose Clean means no changes except untracked files.
   */
  public static final boolean LOSE_CLEAN = false;
}

How to use

Add the following to you section of your pom file.

<plugin>
    <groupId>net.tietema.versioning</groupId>
    <artifactId>versioning-maven-plugin</artifactId>
    <version>1.0</version>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>git-java</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <packageName>com.example</packageName>
        <className>VersionInfo</className>
    </configuration>
</plugin>

The plugin will the run before each maven compile and generate an up to date version of the file. You can then reference the static fields of the class directly into your code.

Notes

  • It is not recommended to commit this file to your SCM.
  • If you build your code directly in your IDE it will probably not directly execute maven, but rather just copy configuration. In that case you need to make sure that the verionsing-maven-plugin:git-java goal runs before the build/make step of your IDE.

Bugs, Contributions and Feedback

All collaboration is done on Github. If you have any suggestions, bugs or contributions, please contact me via Github. Futher enhancesments could be: adding more SCM's or maybe adding more JVM output languages.

License

This plugin is distributed under the Apache License version 2.0

Versions

Version
1.0