Class CommitMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
com.github.koraktor.mavanagaiata.mojo.CommitMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="commit", defaultPhase=INITIALIZE, threadSafe=true) public class CommitMojo extends org.apache.maven.plugin.AbstractMojo
This goal provides the full ID of the current Git commit in the "mavanagaiata.commit.id", "mavanagaiata.commit.sha", "mvngit.commit.id", "mvngit.commit.sha" properties. The abbreviated commit ID is stored in the "mavanagaiata.commit.abbrev" and "mvngit.commit.abbrev" properties. Additionally, the author's and committer's name and email address are stored in the properties "mavanagaiata.commit.author.name", "mavanagaiata.commit.author.email", "mvngit.commit.author.name" and "mvngit.commit.author.email", and "mavanagaiata.commit.committer.name", "mavanagaiata.commit.committer.email", "mvngit.commit.committer.name" and "mvngit.commit.committer.email" respectively.
Since:
0.1.0
Author:
Sebastian Staudt
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
    The date format to use for various dates
    protected org.apache.maven.project.MavenProject
    The Maven project

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

    ROLE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    Generic execution sequence for a Mavanagaiata mojo
    protected GitRepository
    Generic initialization for all Mavanagaiata mojos
    void
    run(GitRepository repository)
    The ID (full and abbreviated) of the current Git commit out Git branch is retrieved using a JGit Repository instance

    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
  • Field Details

    • dateFormat

      @Parameter(property="mavanagaiata.dateFormat", defaultValue="MM/dd/yyyy hh:mm a Z") protected String dateFormat
      The date format to use for various dates
    • project

      @Parameter(defaultValue="${project}", readonly=true) protected org.apache.maven.project.MavenProject project
      The Maven project
  • Constructor Details

    • CommitMojo

      public CommitMojo()
  • Method Details

    • run

      public void run(GitRepository repository) throws com.github.koraktor.mavanagaiata.mojo.MavanagaiataMojoException
      The ID (full and abbreviated) of the current Git commit out Git branch is retrieved using a JGit Repository instance
      Parameters:
      repository - The repository instance to use
      Throws:
      com.github.koraktor.mavanagaiata.mojo.MavanagaiataMojoException - if retrieving information from the Git repository fails
      See Also:
      • AnyObjectId.getName()
      • ObjectReader.abbreviate(org.eclipse.jgit.lib.AnyObjectId, int)
    • execute

      public final void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Generic execution sequence for a Mavanagaiata mojo

      Will initialize any needed resources, run the actual mojo code and cleanup afterwards.

      Throws:
      org.apache.maven.plugin.MojoExecutionException - if the mojo execution fails and failGracefully is false
      org.apache.maven.plugin.MojoFailureException - if the mojo execution fails and failGracefully is true
      See Also:
    • init

      protected GitRepository init() throws com.github.koraktor.mavanagaiata.mojo.MavanagaiataMojoException
      Generic initialization for all Mavanagaiata mojos

      This will initialize the JGit repository instance for further usage by the mojo.

      Returns:
      false if the execution should be skipped
      Throws:
      com.github.koraktor.mavanagaiata.mojo.MavanagaiataMojoException - if the repository cannot be initialized