Class AbstractGitOutputMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- com.github.koraktor.mavanagaiata.mojo.AbstractGitMojo
-
- com.github.koraktor.mavanagaiata.mojo.AbstractGitOutputMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
ChangelogMojo,ContributorsMojo
abstract class AbstractGitOutputMojo extends AbstractGitMojo
This abstract Mojo implements writing output to aPrintStreamThis is eitherSystem.outby default, but maybe anotherPrintStreamobject wrapped around a file given byoutputFile.- Since:
- 0.2.2
- Author:
- Sebastian Staudt
- See Also:
File,PrintStream
-
-
Field Summary
Fields Modifier and Type Field Description (package private) StringencodingThe encoding to use for generated output(package private) StringfooterThe footer to print below the output(package private) PrintStreamprintStream-
Fields inherited from class com.github.koraktor.mavanagaiata.mojo.AbstractGitMojo
baseDir, dateFormat, dirtyFlag, dirtyIgnoreUntracked, failGracefully, gitDir, head, project, propertyPrefixes, skip, skipNoGit
-
-
Constructor Summary
Constructors Constructor Description AbstractGitOutputMojo()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) PrintStreamcreatePrintStream()Creates a new print stream for the configured output file and encoding(package private) voidgenerateOutput(GitRepository repository)Writes the (optional) footer and flushes thePrintStreamafter calling the main mojo implementationabstract FilegetOutputFile()Returns the output file for the generated contentprotected GitRepositoryinit()Initializes the output stream for the generated contentprotected voidinitConfiguration()protected voidrun(GitRepository repository)Initializes thePrintStreamto use This isSystem.outif no output file is given (default).abstract voidsetOutputFile(File outputFile)Sets the output file for the generated content(package private) static StringunescapeFormatNewlines(String format)Unescapes newlines for format stringsprotected abstract voidwriteOutput(GitRepository repository)This must be implemented by mojos for writing their output-
Methods inherited from class com.github.koraktor.mavanagaiata.mojo.AbstractGitMojo
addProperty, execute, initRepository, prepareParameters
-
-
-
-
Field Detail
-
encoding
@Parameter(property="mavanagaiata.encoding", defaultValue="UTF-8") String encodingThe encoding to use for generated output
-
footer
@Parameter(property="mavanagaiata.footer", defaultValue="\nGenerated by Mavanagaiata %s at %s") String footerThe footer to print below the output
-
printStream
PrintStream printStream
-
-
Method Detail
-
unescapeFormatNewlines
static String unescapeFormatNewlines(String format)
Unescapes newlines for format strings- Parameters:
format- The escaped format string- Returns:
- The unescaped format string
-
initConfiguration
protected void initConfiguration()
-
init
protected GitRepository init() throws MavanagaiataMojoException
Initializes the output stream for the generated content- Overrides:
initin classAbstractGitMojo- Returns:
falseif the execution should be skipped- Throws:
MavanagaiataMojoException- if the output file can not be opened
-
getOutputFile
public abstract File getOutputFile()
Returns the output file for the generated contentHas to be implemented by subclassing mojos, so that the output file can be easily configured.
- Returns:
- The output file for the generated content
-
run
protected final void run(GitRepository repository) throws MavanagaiataMojoException
Initializes thePrintStreamto use This isSystem.outif no output file is given (default). Otherwise the parent directories ofoutputFileare created and a newPrintStreamfor that file is created.- Specified by:
runin classAbstractGitMojo- Parameters:
repository- The repository instance to use- Throws:
MavanagaiataMojoException- if the file specified byoutputFilecannot be opened for writing or the target directory cannot be created
-
createPrintStream
PrintStream createPrintStream() throws FileNotFoundException, UnsupportedEncodingException
Creates a new print stream for the configured output file and encoding- Returns:
- A new print stream
- Throws:
FileNotFoundException- if the output file could not be foundUnsupportedEncodingException- if the encoding is not supported
-
setOutputFile
public abstract void setOutputFile(File outputFile)
Sets the output file for the generated content- Parameters:
outputFile- The output file for the generated content
-
writeOutput
protected abstract void writeOutput(GitRepository repository) throws MavanagaiataMojoException
This must be implemented by mojos for writing their output- Parameters:
repository- The repository the mojo is running in- Throws:
MavanagaiataMojoException- if the output cannot be generated
-
generateOutput
void generateOutput(GitRepository repository) throws MavanagaiataMojoException
Writes the (optional) footer and flushes thePrintStreamafter calling the main mojo implementation- Parameters:
repository- The repository the mojo is running in- Throws:
MavanagaiataMojoException- if the output cannot be generated- See Also:
writeOutput(com.github.koraktor.mavanagaiata.git.GitRepository)
-
-