Package org.apache.maven.plugins.pmd
Class CpdViolationCheckMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.plugins.pmd.AbstractPmdViolationCheckMojo<Duplication>
org.apache.maven.plugins.pmd.CpdViolationCheckMojo
- All Implemented Interfaces:
ContextEnabled
,Mojo
- Direct Known Subclasses:
AggregatorCpdViolationCheckMojo
@Mojo(name="cpd-check",
defaultPhase=VERIFY,
threadSafe=true)
@Execute(goal="cpd")
public class CpdViolationCheckMojo
extends AbstractPmdViolationCheckMojo<Duplication>
Fails the build if there were any CPD violations in the source code.
- Since:
- 2.0
- Version:
- $Id$
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Whether to fail the build if the validation check fails.Fields inherited from class org.apache.maven.plugins.pmd.AbstractPmdViolationCheckMojo
aggregate, project
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
protected List<Duplication>
getErrorDetails
(File cpdFile) Gets the attributes and text for the violation tag and puts them in a HashMapprotected int
getPriority
(Duplication errorDetail) boolean
protected ViolationDetails<Duplication>
protected void
printError
(Duplication 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, printErrors
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
failOnViolation
@Parameter(property="cpd.failOnViolation", defaultValue="true", required=true) protected boolean failOnViolationWhether to fail the build if the validation check fails.- Since:
- 3.0
-
-
Constructor Details
-
CpdViolationCheckMojo
public CpdViolationCheckMojo()Default constructor. Initializes with the correctExcludeDuplicationsFromFile
.
-
-
Method Details
-
execute
-
printError
Formats the failure details and prints them as an INFO message- Specified by:
printError
in classAbstractPmdViolationCheckMojo<Duplication>
- 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<Duplication> getErrorDetails(File cpdFile) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException Gets the attributes and text for the violation tag and puts them in a HashMap- Specified by:
getErrorDetails
in classAbstractPmdViolationCheckMojo<Duplication>
- Parameters:
cpdFile
- 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<Duplication>
-
newViolationDetailsInstance
- Specified by:
newViolationDetailsInstance
in classAbstractPmdViolationCheckMojo<Duplication>
-
isFailOnViolation
public boolean isFailOnViolation()- Overrides:
isFailOnViolation
in classAbstractPmdViolationCheckMojo<Duplication>
-