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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
getErrorDetails
(File pmdFile) Gets the attributes and text for the violation tag and puts them in a HashMapprotected int
getPriority
(Violation errorDetail) protected ViolationDetails<Violation>
protected void
printError
(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, printErrors
Methods 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:
printError
in classAbstractPmdViolationCheckMojo<Violation>
- Parameters:
item
- either aViolation
from PMD or aDuplication
from 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:AbstractPmdViolationCheckMojo
Gets the attributes and text for the violation tag and puts them in a HashMap- Specified by:
getErrorDetails
in classAbstractPmdViolationCheckMojo<Violation>
- Parameters:
pmdFile
- the xml output from PMD or CPD- Returns:
- all PMD
Violation
s or CPDDuplication
s. - 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:
getPriority
in classAbstractPmdViolationCheckMojo<Violation>
-
newViolationDetailsInstance
- Specified by:
newViolationDetailsInstance
in classAbstractPmdViolationCheckMojo<Violation>
-