Class AbstractGitMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- com.github.koraktor.mavanagaiata.mojo.AbstractGitMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
AbstractGitOutputMojo,BranchMojo,CheckMojo,CommitMojo,InfoClassMojo,TagMojo
abstract class AbstractGitMojo extends org.apache.maven.plugin.AbstractMojoThis abstract Mojo implements initializing a JGit Repository and provides this Repository instance to subclasses.- Since:
- 0.1.0
- Author:
- Sebastian Staudt
- See Also:
GitRepository
-
-
Field Summary
Fields Modifier and Type Field Description (package private) FilebaseDirThe working tree of the Git repository.protected StringdateFormatThe date format to use for various dates(package private) StringdirtyFlagThe flag to append to refs if there are changes in the index or working tree(package private) booleandirtyIgnoreUntrackedSpecifies if the dirty flag should also be appended if there are untracked files(package private) booleanfailGracefullySpecifies if a failed execution of the mojo will stop the build process(package private) FilegitDirTheGIT_DIRpath of the Git repository(package private) StringheadThe commit or ref to use as starting point for operationsprotected org.apache.maven.project.MavenProjectprojectThe Maven project(package private) String[]propertyPrefixesThe prefixes to prepend to property keys(package private) booleanskipSkip the plugin execution(package private) booleanskipNoGitSkip the plugin execution if not inside a Git repository
-
Constructor Summary
Constructors Constructor Description AbstractGitMojo()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) voidaddProperty(String name, String value)Saves a property with the given name into the project's properties The value will be stored two times – with "mavanagaiata" and "mvngit" as a prefix.voidexecute()Generic execution sequence for a Mavanagaiata mojoprotected GitRepositoryinit()Generic initialization for all Mavanagaiata mojos(package private) GitRepositoryinitRepository()Initializes a JGit Repository object for further reference(package private) voidprepareParameters()Prepares and validates user-supplied parametersprotected abstract voidrun(GitRepository repository)The actual implementation of the mojo
-
-
-
Field Detail
-
dateFormat
@Parameter(property="mavanagaiata.dateFormat", defaultValue="MM/dd/yyyy hh:mm a Z") protected String dateFormatThe date format to use for various dates
-
baseDir
@Parameter(property="mavanagaiata.baseDir", defaultValue="${project.basedir}") File baseDirThe working tree of the Git repository.If there is only one project inside the Git repository this is probably
${project.basedir}(default).Note: The
GIT_DIRcan be found automatically even if this is not the real working tree but one of its subdirectories. But Mavanagaiata cannot determine the state of the working tree (e.g. for the dirty flag) if this is not set correctly.
-
dirtyFlag
@Parameter(property="mavanagaiata.dirtyFlag", defaultValue="-dirty") String dirtyFlagThe flag to append to refs if there are changes in the index or working treeSetting this to either
"false"or"null"will disable flagging refs as dirty.- Since:
- 0.4.0
-
dirtyIgnoreUntracked
@Parameter(property="mavanagaiata.dirtyIgnoreUntracked", defaultValue="false") boolean dirtyIgnoreUntrackedSpecifies if the dirty flag should also be appended if there are untracked filesIf
falseonly modified files that are already known to Git will cause the dirty flag to be appended.Warning: Do not enable this if builds should be reproducible.
- Since:
- 0.5.0
-
failGracefully
@Parameter(property="mavanagaiata.failGracefully", defaultValue="false") boolean failGracefullySpecifies if a failed execution of the mojo will stop the build processIf
truea failure during mojo execution will not stop the build process.- Since:
- 0.6.0
-
gitDir
@Parameter(property="mavanagaiata.gitDir") File gitDir
TheGIT_DIRpath of the Git repositoryWarning: Do not set this when you don't have a good reason to do so. The
GIT_DIRcan be found automatically if your project resides somewhere in a usual Git repository.
-
head
@Parameter(property="mavanagaiata.head", defaultValue="HEAD") String headThe commit or ref to use as starting point for operations
-
skip
@Parameter(property="mavanagaiata.skip", defaultValue="false") boolean skipSkip the plugin execution- Since:
- 0.5.0
-
skipNoGit
@Parameter(property="mavanagaiata.skipNoGit", defaultValue="false") boolean skipNoGitSkip the plugin execution if not inside a Git repository- Since:
- 0.5.0
-
project
@Parameter(defaultValue="${project}", readonly=true) protected org.apache.maven.project.MavenProject projectThe Maven project
-
propertyPrefixes
@Parameter(property="mavanagaiata.propertyPrefixes", defaultValue="mavanagaiata,mvngit") String[] propertyPrefixesThe prefixes to prepend to property keys
-
-
Method Detail
-
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 andfailGracefullyisfalseorg.apache.maven.plugin.MojoFailureException- if the mojo execution fails andfailGracefullyistrue- See Also:
init(),run(com.github.koraktor.mavanagaiata.git.GitRepository)
-
addProperty
void addProperty(String name, String value)
Saves a property with the given name into the project's properties The value will be stored two times – with "mavanagaiata" and "mvngit" as a prefix.- Parameters:
name- The property namevalue- The value of the property
-
init
protected GitRepository init() throws MavanagaiataMojoException
Generic initialization for all Mavanagaiata mojosThis will initialize the JGit repository instance for further usage by the mojo.
- Returns:
falseif the execution should be skipped- Throws:
MavanagaiataMojoException- if the repository cannot be initialized
-
initRepository
GitRepository initRepository() throws GitRepositoryException
Initializes a JGit Repository object for further reference- Returns:
- The repository instance
- Throws:
GitRepositoryException- if retrieving information from the Git repository fails
-
prepareParameters
void prepareParameters()
Prepares and validates user-supplied parameters
-
run
protected abstract void run(GitRepository repository) throws MavanagaiataMojoException
The actual implementation of the mojo- Parameters:
repository- The repository instance to use- Throws:
MavanagaiataMojoException- if there is an error during execution
-
-