Class GitCommitIdMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
pl.project13.maven.git.GitCommitIdMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="revision", defaultPhase=INITIALIZE, threadSafe=true) public class GitCommitIdMojo extends org.apache.maven.plugin.AbstractMojo
Puts git build-time information into property files or maven's properties.
Since:
1.0
  • Field Summary

    Fields inherited from interface org.apache.maven.plugin.Mojo

    ROLE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    protected Map<String,String>
    This method is used to mock the system environment in testing.
    protected static Date
    parseOutputTimestamp(String outputTimestamp)
    Parse output timestamp configured for Reproducible Builds' archive entries (https://maven.apache.org/guides/mini/guide-reproducible-builds.html).

    Methods inherited from class org.apache.maven.plugin.AbstractMojo

    getLog, getPluginContext, setLog, setPluginContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GitCommitIdMojo

      public GitCommitIdMojo()
  • Method Details

    • getCustomSystemEnv

      protected Map<String,String> getCustomSystemEnv()
      This method is used to mock the system environment in testing.
      Returns:
      unmodifiable string map view of the current system environment System.getenv(java.lang.String).
    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • parseOutputTimestamp

      protected static Date parseOutputTimestamp(String outputTimestamp)
      Parse output timestamp configured for Reproducible Builds' archive entries (https://maven.apache.org/guides/mini/guide-reproducible-builds.html). The value from ${project.build.outputTimestamp} is either formatted as ISO 8601 yyyy-MM-dd'T'HH:mm:ssXXX or as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH.

      Inspired by https://github.com/apache/maven-archiver/blob/7acb1db4a9754beacde3f21a69e5523ee901abd5/src/main/java/org/apache/maven/archiver/MavenArchiver.java#L755

      Parameters:
      outputTimestamp - the value of ${project.build.outputTimestamp} (may be null)
      Returns:
      the parsed timestamp, may be null if null input or input contains only 1 character