Class CheckMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- com.github.koraktor.mavanagaiata.mojo.AbstractGitMojo
-
- com.github.koraktor.mavanagaiata.mojo.CheckMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="check", defaultPhase=VALIDATE, threadSafe=true) public class CheckMojo extends AbstractGitMojoThis goal checks various aspects of a Git repository to ensure it is in a valid state prior to a buildThe following checks are available:
- Clean working directory (enabled by default)
- Tagged commit
- Branch name
- Commit message
- Since:
- 0.8.0
- Author:
- Sebastian Staudt
-
-
Field Summary
Fields Modifier and Type Field Description (package private) StringcheckBranchCheck whether the current branch is the given branch(package private) booleancheckCleanCheck if the working directory is clean(package private) StringcheckCommitMessageCheck whether the message of the current commit matches the given format(package private) booleancheckTagCheck whether the current commit is tagged(package private) PatterncommitMessagePattern-
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 CheckMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckBranch(GitRepository repository)Checks if the branch matches the configured nameprivate voidcheckClean(GitRepository repository)Checks if the worktree is in a clean stateprivate voidcheckCommitMessage(GitRepository repository)Checks if commit message matches the configured patternprivate voidcheckTag(GitRepository repository)Checks if the the currentHEADis taggedprotected GitRepositoryinit()Generic initialization for all Mavanagaiata mojos(package private) voidinitConfiguration()Compiles the commit message check regexprotected voidrun(GitRepository repository)The actual implementation of the mojo-
Methods inherited from class com.github.koraktor.mavanagaiata.mojo.AbstractGitMojo
addProperty, execute, initRepository, prepareParameters
-
-
-
-
Field Detail
-
commitMessagePattern
Pattern commitMessagePattern
-
checkBranch
@Parameter(property="mavanagaiata.checkBranch") String checkBranch
Check whether the current branch is the given branch
-
checkClean
@Parameter(property="mavanagaiata.checkClean", defaultValue="true") boolean checkCleanCheck if the working directory is clean
-
checkCommitMessage
@Parameter(property="mavanagaiata.checkCommitMessage") String checkCommitMessage
Check whether the message of the current commit matches the given format
-
checkTag
@Parameter(property="mavanagaiata.checkTag", defaultValue="false") boolean checkTagCheck whether the current commit is tagged
-
-
Method Detail
-
init
protected GitRepository init() throws MavanagaiataMojoException
Description copied from class:AbstractGitMojoGeneric initialization for all Mavanagaiata mojosThis will initialize the JGit repository instance for further usage by the mojo.
- Overrides:
initin classAbstractGitMojo- Returns:
falseif the execution should be skipped- Throws:
MavanagaiataMojoException- if the repository cannot be initialized
-
initConfiguration
void initConfiguration()
Compiles the commit message check regex
-
run
protected void run(GitRepository repository) throws MavanagaiataMojoException
Description copied from class:AbstractGitMojoThe actual implementation of the mojo- Specified by:
runin classAbstractGitMojo- Parameters:
repository- The repository instance to use- Throws:
MavanagaiataMojoException- if there is an error during execution
-
checkBranch
private void checkBranch(GitRepository repository) throws CheckMojoException, GitRepositoryException
Checks if the branch matches the configured name- Parameters:
repository- The repository instance to check- Throws:
CheckMojoException- if the branch does not matchGitRepositoryException- if the current branch cannot be retrieved- See Also:
checkBranch
-
checkClean
private void checkClean(GitRepository repository) throws CheckMojoException, GitRepositoryException
Checks if the worktree is in a clean state- Parameters:
repository- The repository instance to check- Throws:
CheckMojoException- if the worktree is not cleanGitRepositoryException- if the worktree state cannot be retrieved- See Also:
checkClean
-
checkCommitMessage
private void checkCommitMessage(GitRepository repository) throws GitRepositoryException, CheckMojoException
Checks if commit message matches the configured pattern- Parameters:
repository- The repository instance to check- Throws:
CheckMojoException- if the commit message does not matchGitRepositoryException- if the current commit cannot be retrieved- See Also:
checkCommitMessage
-
checkTag
private void checkTag(GitRepository repository) throws GitRepositoryException, CheckMojoException
Checks if the the currentHEADis tagged- Parameters:
repository- The repository instance to check- Throws:
CheckMojoException- ifHEADis not taggedGitRepositoryException- if the commit cannot be described- See Also:
checkTag
-
-