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:
- org.apache.maven.plugin.ContextEnabled,- org.apache.maven.plugin.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
- 
Field SummaryFields inherited from class org.apache.maven.plugins.pmd.AbstractPmdViolationCheckMojoaggregate, failOnViolation, projectFields inherited from interface org.apache.maven.plugin.MojoROLE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier 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.AbstractPmdViolationCheckMojoexecuteCheck, getMaxAllowedViolations, isAggregator, isFailOnViolation, printErrorsMethods inherited from class org.apache.maven.plugin.AbstractMojogetLog, getPluginContext, setLog, setPluginContext
- 
Constructor Details- 
PmdViolationCheckMojopublic PmdViolationCheckMojo()Default constructor. Initializes with the correctExcludeViolationsFromFile.
 
- 
- 
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<Violation>
- 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<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 class- AbstractPmdViolationCheckMojo<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 XML
- IOException- if the analysis file could be read
 
- 
getPriority- Specified by:
- getPriorityin class- AbstractPmdViolationCheckMojo<Violation>
 
- 
newViolationDetailsInstance- Specified by:
- newViolationDetailsInstancein class- AbstractPmdViolationCheckMojo<Violation>
 
 
-