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
FieldsModifier and TypeFieldDescriptionprotected String
The date format to use for various datesprotected ChangelogFormat
The format to use while generating the changelogprotected File
The file to write the changelog toprotected org.apache.maven.project.MavenProject
The Maven projectFields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal void
execute()
Generic execution sequence for a Mavanagaiata mojoReturns the output file for the generated changelogprotected GitRepository
init()
Initializes the output stream for the generated contentprotected void
protected final void
run
(GitRepository repository) Initializes thePrintStream
to usevoid
setOutputFile
(File outputFile) Sets the output file for the generated changelogprotected void
writeOutput
(GitRepository repository) 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
-
Field Details
-
format
The format to use while generating the changelog- Since:
- 0.9.0
- See Also:
-
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 dateFormatThe date format to use for various dates -
project
@Parameter(defaultValue="${project}", readonly=true) protected org.apache.maven.project.MavenProject projectThe 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
Returns the output file for the generated changelog- Returns:
- The output file for the generated changelog
-
initConfiguration
protected void initConfiguration() -
setOutputFile
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.MavanagaiataMojoExceptionInitializes 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 thePrintStream
to useThis is
System.out
if no output file is given (default). Otherwise the parent directories ofoutputFile
are created and a newPrintStream
for that file is created.- Parameters:
repository
- The repository instance to use- Throws:
com.github.koraktor.mavanagaiata.mojo.MavanagaiataMojoException
- if the file specified byoutputFile
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.MojoFailureExceptionGeneric execution sequence for a Mavanagaiata mojoWill initialize any needed resources, run the actual mojo code and cleanup afterwards.
- Throws:
org.apache.maven.plugin.MojoExecutionException
- if the mojo execution fails andfailGracefully
isfalse
org.apache.maven.plugin.MojoFailureException
- if the mojo execution fails andfailGracefully
istrue
- See Also:
-