Class ChangelogMojo

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

@Mojo(name="changelog", defaultPhase=PROCESS_RESOURCES, threadSafe=true) public class ChangelogMojo extends org.apache.maven.plugin.AbstractMojo
This goal allows to generate a changelog of the currently checked out branch of the Git repository. It will use information from tags and commit messages to build a reverse chronological summary of the development. It can be configured to display the changelog or save it to a file.
Since:
0.2.0
Author:
Sebastian Staudt
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
    The date format to use for various dates
    protected ChangelogFormat
    The format to use while generating the changelog
    protected File
    The file to write the changelog to
    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
    Returns the output file for the generated changelog
    protected GitRepository
    Initializes the output stream for the generated content
    protected void
     
    protected final void
    run(GitRepository repository)
    Initializes the PrintStream to use
    void
    setOutputFile(File outputFile)
    Sets the output file for the generated changelog
    protected void
    Walks through the history of the currently checked out branch of the Git repository and builds a changelog from the commits contained in that branch.

    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

    • format

      @Parameter(property="mavanagaiata.changelog.format") protected ChangelogFormat format
      The format to use while generating the changelog
      Since:
      0.9.0
      See Also:
      • formatTemplate
    • outputFile

      @Parameter(property="mavanagaiata.changelog.outputFile") protected File outputFile
      The file to write the changelog to
      Since:
      0.4.1
    • 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

    • ChangelogMojo

      public ChangelogMojo()
  • Method Details

    • writeOutput

      protected void writeOutput(GitRepository repository) throws com.github.koraktor.mavanagaiata.mojo.MavanagaiataMojoException
      Walks through the history of the currently checked out branch of the Git repository and builds a changelog from the commits contained in that branch.
      Parameters:
      repository - The repository the mojo is running in
      Throws:
      com.github.koraktor.mavanagaiata.mojo.MavanagaiataMojoException - if retrieving information from the Git repository fails
    • getOutputFile

      public File getOutputFile()
      Returns the output file for the generated changelog
      Returns:
      The output file for the generated changelog
    • initConfiguration

      protected void initConfiguration()
    • setOutputFile

      public void setOutputFile(File outputFile)
      Sets the output file for the generated changelog
      Parameters:
      outputFile - The output file for the generated changelog
    • init

      protected GitRepository init() throws com.github.koraktor.mavanagaiata.mojo.MavanagaiataMojoException
      Initializes the output stream for the generated content
      Returns:
      false if the execution should be skipped
      Throws:
      com.github.koraktor.mavanagaiata.mojo.MavanagaiataMojoException - if the output file can not be opened
    • run

      protected final void run(GitRepository repository) throws com.github.koraktor.mavanagaiata.mojo.MavanagaiataMojoException
      Initializes the PrintStream to use

      This is System.out if no output file is given (default). Otherwise the parent directories of outputFile are created and a new PrintStream for that file is created.

      Parameters:
      repository - The repository instance to use
      Throws:
      com.github.koraktor.mavanagaiata.mojo.MavanagaiataMojoException - if the file specified by outputFile cannot be opened for writing or the target directory cannot be created
    • 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: