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:
- org.apache.maven.plugin.ContextEnabled,- org.apache.maven.plugin.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
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected booleanWhether to fail the build if the validation check fails.Fields inherited from class org.apache.maven.plugins.pmd.AbstractPmdViolationCheckMojoaggregate, projectFields inherited from interface org.apache.maven.plugin.MojoROLE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidexecute()protected List<Duplication> getErrorDetails(File cpdFile) Gets the attributes and text for the violation tag and puts them in a HashMapprotected intgetPriority(Duplication errorDetail) booleanprotected ViolationDetails<Duplication> protected voidprintError(Duplication item, String severity) Formats the failure details and prints them as an INFO messageMethods inherited from class org.apache.maven.plugins.pmd.AbstractPmdViolationCheckMojoexecuteCheck, getMaxAllowedViolations, isAggregator, printErrorsMethods inherited from class org.apache.maven.plugin.AbstractMojogetLog, 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- 
CpdViolationCheckMojopublic CpdViolationCheckMojo()Default constructor. Initializes with the correctExcludeDuplicationsFromFile.
 
- 
- 
Method Details- 
executepublic void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
- org.apache.maven.plugin.MojoExecutionException
- org.apache.maven.plugin.MojoFailureException
 
- 
printErrorFormats the failure details and prints them as an INFO message- Specified by:
- printErrorin class- AbstractPmdViolationCheckMojo<Duplication>
- Parameters:
- item- either a- Violationfrom PMD or a- Duplicationfrom CPD
- severity- the found issue is prefixed with the given severity, usually "Warning" or "Failure".
 
- 
getErrorDetailsprotected 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:
- getErrorDetailsin class- AbstractPmdViolationCheckMojo<Duplication>
- Parameters:
- cpdFile- 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 XML
- IOException- if the analysis file could be read
 
- 
getPriority- Specified by:
- getPriorityin class- AbstractPmdViolationCheckMojo<Duplication>
 
- 
newViolationDetailsInstance- Specified by:
- newViolationDetailsInstancein class- AbstractPmdViolationCheckMojo<Duplication>
 
- 
isFailOnViolationpublic boolean isFailOnViolation()- Overrides:
- isFailOnViolationin class- AbstractPmdViolationCheckMojo<Duplication>
 
 
-