Class InfoClassMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- com.github.koraktor.mavanagaiata.mojo.AbstractGitMojo
-
- com.github.koraktor.mavanagaiata.mojo.InfoClassMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="info-class", defaultPhase=GENERATE_SOURCES, threadSafe=true) public class InfoClassMojo extends AbstractGitMojoThis goal generates the source code for a Java class with Git information like commit ID and tag name.- Since:
- 0.5.0
- Author:
- Sebastian Staudt
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classInfoClassMojo.ValueSourceFilter
-
Field Summary
Fields Modifier and Type Field Description private static StringBUILTIN_TEMPLATE_PATH(package private) StringclassNameThe name of the class to generate(package private) StringencodingThe encoding of the generated source file(package private) org.apache.maven.shared.filtering.MavenFileFilterfileFilter(package private) FileoutputDirectoryThe directory to write the source code to(package private) StringpackageNameThe name of the package in which the class will be generatedprivate FiletemplateFileThe path to an alternative template for the info class-
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 InfoClassMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private FilecopyTemporaryTemplate()(package private) InputStreamgetTemplateSource()Returns an input stream for the template source file for the info class(package private) org.codehaus.plexus.interpolation.MapBasedValueSourcegetValueSource(GitRepository repository)voidrun(GitRepository repository)Generates a info class filled providing information of the Git repositoryprivate voidwriteSourceFile(GitRepository repository, File sourceFile)-
Methods inherited from class com.github.koraktor.mavanagaiata.mojo.AbstractGitMojo
addProperty, execute, init, initRepository, prepareParameters
-
-
-
-
Field Detail
-
BUILTIN_TEMPLATE_PATH
private static final String BUILTIN_TEMPLATE_PATH
- See Also:
- Constant Field Values
-
className
@Parameter(property="mavanagaiata.info-class.className", defaultValue="GitInfo") String classNameThe name of the class to generate
-
encoding
@Parameter(property="mavanagaiata.info-class.encoding", defaultValue="${project.build.sourceEncoding}") String encodingThe encoding of the generated source file
-
fileFilter
@Component org.apache.maven.shared.filtering.MavenFileFilter fileFilter
-
packageName
@Parameter(property="mavanagaiata.info-class.packageName", defaultValue="${project.groupId}.${project.artifactId}") String packageNameThe name of the package in which the class will be generated
-
outputDirectory
@Parameter(property="mavanagaiata.info-class.outputDirectory", defaultValue="${project.build.directory}/generated-sources/mavanagaiata") File outputDirectoryThe directory to write the source code toThis directory is automatically added to the source roots used to compile the project.
-
templateFile
@Parameter(property="mavanagaiata.info-class.templatePath") private File templateFile
The path to an alternative template for the info class
-
-
Method Detail
-
getTemplateSource
InputStream getTemplateSource() throws FileNotFoundException
Returns an input stream for the template source file for the info classThis may either be the builtin template or an arbitrary source file set via
templatePath.- Returns:
- An input stream for the template source file
- Throws:
FileNotFoundException- if the template source cannot be found
-
run
public void run(GitRepository repository) throws MavanagaiataMojoException
Generates a info class filled providing information of the Git repository- Specified by:
runin classAbstractGitMojo- Parameters:
repository- The repository instance to use- Throws:
MavanagaiataMojoException- if the info class cannot be generated
-
copyTemporaryTemplate
private File copyTemporaryTemplate() throws IOException, MavanagaiataMojoException
- Throws:
IOExceptionMavanagaiataMojoException
-
getValueSource
org.codehaus.plexus.interpolation.MapBasedValueSource getValueSource(GitRepository repository) throws GitRepositoryException
- Throws:
GitRepositoryException
-
writeSourceFile
private void writeSourceFile(GitRepository repository, File sourceFile) throws GitRepositoryException, MavanagaiataMojoException, org.apache.maven.shared.filtering.MavenFilteringException
- Throws:
GitRepositoryExceptionMavanagaiataMojoExceptionorg.apache.maven.shared.filtering.MavenFilteringException
-
-