Package org.apache.maven.plugins.pmd
Class PmdViolationCheckMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugins.pmd.AbstractPmdViolationCheckMojo<Violation>
-
- org.apache.maven.plugins.pmd.PmdViolationCheckMojo
-
- All Implemented Interfaces:
ContextEnabled,Mojo
@Mojo(name="check", defaultPhase=VERIFY, threadSafe=true) @Execute(goal="pmd") public class PmdViolationCheckMojo extends AbstractPmdViolationCheckMojo<Violation>
Fail the build if there were any PMD violations in the source code.- Since:
- 2.0
- Version:
- $Id$
-
-
Field Summary
-
Fields inherited from class org.apache.maven.plugins.pmd.AbstractPmdViolationCheckMojo
aggregate, failOnViolation, project
-
-
Constructor Summary
Constructors Constructor Description PmdViolationCheckMojo()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute()protected java.util.List<Violation>getErrorDetails(java.io.File pmdFile)Gets the attributes and text for the violation tag and puts them in a HashMapprotected intgetPriority(Violation errorDetail)protected ViolationDetails<Violation>newViolationDetailsInstance()protected voidprintError(Violation item, java.lang.String severity)Formats the failure details and prints them as an INFO message-
Methods inherited from class org.apache.maven.plugins.pmd.AbstractPmdViolationCheckMojo
executeCheck, getMaxAllowedViolations, isFailOnViolation, printErrors
-
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
-
-
-
Constructor Detail
-
PmdViolationCheckMojo
public PmdViolationCheckMojo()
Default constructor. Initializes with the correctExcludeViolationsFromFile.
-
-
Method Detail
-
execute
public void execute() throws MojoExecutionException, MojoFailureException
-
printError
protected void printError(Violation item, java.lang.String severity)
Formats the failure details and prints them as an INFO message- Specified by:
printErrorin classAbstractPmdViolationCheckMojo<Violation>- Parameters:
item- either aViolationfrom PMD or aDuplicationfrom CPDseverity- the found issue is prefixed with the given severity, usually "Warning" or "Failure".
-
getErrorDetails
protected java.util.List<Violation> getErrorDetails(java.io.File pmdFile) throws XmlPullParserException, java.io.IOException
Description copied from class:AbstractPmdViolationCheckMojoGets the attributes and text for the violation tag and puts them in a HashMap- Specified by:
getErrorDetailsin classAbstractPmdViolationCheckMojo<Violation>- Parameters:
pmdFile- the xml output from PMD or CPD- Returns:
- all PMD
Violations or CPDDuplications. - Throws:
XmlPullParserException- if the analysis file contains invalid XMLjava.io.IOException- if the analysis file could be read
-
getPriority
protected int getPriority(Violation errorDetail)
- Specified by:
getPriorityin classAbstractPmdViolationCheckMojo<Violation>
-
newViolationDetailsInstance
protected ViolationDetails<Violation> newViolationDetailsInstance()
- Specified by:
newViolationDetailsInstancein classAbstractPmdViolationCheckMojo<Violation>
-
-