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
@Mojo(name="cpd-check", defaultPhase=VERIFY, threadSafe=true) @Execute(goal="cpd") public class CpdViolationCheckMojo extends AbstractPmdViolationCheckMojo<Duplication>
Fail the build if there were any CPD violations in the source code.- Since:
- 2.0
- Version:
- $Id$
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanfailOnViolationWhether to fail the build if the validation check fails.-
Fields inherited from class org.apache.maven.plugins.pmd.AbstractPmdViolationCheckMojo
aggregate, project
-
-
Constructor Summary
Constructors Constructor Description CpdViolationCheckMojo()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute()protected java.util.List<Duplication>getErrorDetails(java.io.File cpdFile)Gets the attributes and text for the violation tag and puts them in a HashMapprotected intgetPriority(Duplication errorDetail)booleanisFailOnViolation()protected ViolationDetails<Duplication>newViolationDetailsInstance()protected voidprintError(Duplication 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, printErrors
-
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
-
-
-
Field Detail
-
failOnViolation
@Parameter(property="cpd.failOnViolation", defaultValue="true", required=true) protected boolean failOnViolation
Whether to fail the build if the validation check fails.- Since:
- 3.0
-
-
Constructor Detail
-
CpdViolationCheckMojo
public CpdViolationCheckMojo()
Default constructor. Initializes with the correctExcludeDuplicationsFromFile.
-
-
Method Detail
-
execute
public void execute() throws MojoExecutionException, MojoFailureException
-
printError
protected void printError(Duplication item, java.lang.String severity)
Formats the failure details and prints them as an INFO message- Specified by:
printErrorin classAbstractPmdViolationCheckMojo<Duplication>- 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<Duplication> getErrorDetails(java.io.File cpdFile) throws XmlPullParserException, java.io.IOException
Gets the attributes and text for the violation tag and puts them in a HashMap- Specified by:
getErrorDetailsin classAbstractPmdViolationCheckMojo<Duplication>- Parameters:
cpdFile- 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(Duplication errorDetail)
- Specified by:
getPriorityin classAbstractPmdViolationCheckMojo<Duplication>
-
newViolationDetailsInstance
protected ViolationDetails<Duplication> newViolationDetailsInstance()
- Specified by:
newViolationDetailsInstancein classAbstractPmdViolationCheckMojo<Duplication>
-
isFailOnViolation
public boolean isFailOnViolation()
- Overrides:
isFailOnViolationin classAbstractPmdViolationCheckMojo<Duplication>
-
-