Package org.apache.maven.plugins.pmd
Class AbstractPmdViolationCheckMojo<D>
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.plugins.pmd.AbstractPmdViolationCheckMojo<D>
- Type Parameters:
- D- type of the check, e.g.- Violationor- Duplication.
- All Implemented Interfaces:
- org.apache.maven.plugin.ContextEnabled,- org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
- CpdViolationCheckMojo,- PmdViolationCheckMojo
public abstract class AbstractPmdViolationCheckMojo<D>
extends org.apache.maven.plugin.AbstractMojo
Base class for mojos that check if there were any PMD violations.
- Version:
- $Id$
- Author:
- Brett Porter
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected booleanDeprecated.protected booleanWhether to fail the build if the validation check fails.protected org.apache.maven.project.MavenProjectThe project to analyze.Fields inherited from interface org.apache.maven.plugin.MojoROLE
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedAbstractPmdViolationCheckMojo(ExcludeFromFile<D> excludeFromFile) Initialize this abstract check mojo by giving the correct ExcludeFromFile helper.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidexecuteCheck(String filename, String analyzerName, String failureName, int failurePriority) getErrorDetails(File analysisFile) Gets the attributes and text for the violation tag and puts them in a HashMapprotected abstract intgetPriority(D errorDetail) protected booleanbooleanprotected abstract ViolationDetails<D> protected abstract voidprintError(D item, String severity) Formats the failure details and prints them as an INFO messageprotected voidprintErrors(List<D> failures, List<D> warnings) Prints the warnings and failuresMethods inherited from class org.apache.maven.plugin.AbstractMojogetLog, getPluginContext, setLog, setPluginContextMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.maven.plugin.Mojoexecute
- 
Field Details- 
failOnViolation@Parameter(property="pmd.failOnViolation", defaultValue="true", required=true) protected boolean failOnViolationWhether to fail the build if the validation check fails. The propertiesfailurePriorityandmaxAllowedViolationscontrol under which conditions exactly the build should be failed.
- 
aggregateDeprecated.since 3.15.0 Use the goalpmd:aggregate-checkorpmd:aggregate-cpd-checkinstead.Whether to build an aggregated report at the root, or build individual reports.- Since:
- 2.2
 
- 
project@Parameter(defaultValue="${project}", readonly=true, required=true) protected org.apache.maven.project.MavenProject projectThe project to analyze.
 
- 
- 
Constructor Details- 
AbstractPmdViolationCheckMojoInitialize this abstract check mojo by giving the correct ExcludeFromFile helper.- Parameters:
- excludeFromFile- the needed helper, for the specific violation type
 
 
- 
- 
Method Details- 
executeCheckprotected void executeCheck(String filename, String analyzerName, String failureName, int failurePriority) throws org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionException - Throws:
- org.apache.maven.plugin.MojoFailureException
- org.apache.maven.plugin.MojoExecutionException
 
- 
getPriority
- 
newViolationDetailsInstance
- 
printErrorsPrints the warnings and failures- Parameters:
- failures- list of failures
- warnings- list of warnings
 
- 
printErrorFormats the failure details and prints them as an INFO message- 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 abstract List<D> getErrorDetails(File analysisFile) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException Gets the attributes and text for the violation tag and puts them in a HashMap- Parameters:
- analysisFile- 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
 
- 
isFailOnViolationpublic boolean isFailOnViolation()
- 
getMaxAllowedViolations
- 
isAggregatorprotected boolean isAggregator()
 
- 
pmd:aggregate-checkorpmd:aggregate-cpd-checkinstead.