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
- Direct Known Subclasses:
AggregatorPmdViolationCheckMojo
@Mojo(name="check",
defaultPhase=VERIFY,
threadSafe=true)
@Execute(goal="pmd")
public class PmdViolationCheckMojo
extends AbstractPmdViolationCheckMojo<Violation>
Fails 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 -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute()getErrorDetails(File pmdFile) Gets the attributes and text for the violation tag and puts them in a HashMapprotected intgetPriority(Violation errorDetail) protected ViolationDetails<Violation>protected voidprintError(Violation item, String severity) Formats the failure details and prints them as an INFO messageMethods inherited from class org.apache.maven.plugins.pmd.AbstractPmdViolationCheckMojo
executeCheck, getMaxAllowedViolations, isAggregator, isFailOnViolation, printErrorsMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Constructor Details
-
PmdViolationCheckMojo
public PmdViolationCheckMojo()Default constructor. Initializes with the correctExcludeViolationsFromFile.
-
-
Method Details
-
execute
-
printError
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 List<Violation> getErrorDetails(File pmdFile) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, 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:
org.codehaus.plexus.util.xml.pull.XmlPullParserException- if the analysis file contains invalid XMLIOException- if the analysis file could be read
-
getPriority
- Specified by:
getPriorityin classAbstractPmdViolationCheckMojo<Violation>
-
newViolationDetailsInstance
- Specified by:
newViolationDetailsInstancein classAbstractPmdViolationCheckMojo<Violation>
-