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.Violation
orDuplication
.
- All Implemented Interfaces:
ContextEnabled
,Mojo
- Direct Known Subclasses:
CpdViolationCheckMojo
,PmdViolationCheckMojo
Base class for mojos that check if there were any PMD violations.
- Version:
- $Id$
- Author:
- Brett Porter
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
Deprecated.protected boolean
Whether to fail the build if the validation check fails.protected MavenProject
The project to analyze. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractPmdViolationCheckMojo
(ExcludeFromFile<D> excludeFromFile) Initialize this abstact check mojo by giving the correct ExcludeFromFile helper. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
executeCheck
(String filename, String tagName, String key, int failurePriority) getErrorDetails
(File analysisFile) Gets the attributes and text for the violation tag and puts them in a HashMapprotected abstract int
getPriority
(D errorDetail) protected boolean
boolean
protected abstract ViolationDetails<D>
protected abstract void
printError
(D item, String severity) Formats the failure details and prints them as an INFO messageprotected void
printErrors
(List<D> failures, List<D> warnings) Prints the warnings and failuresMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
failOnViolation
@Parameter(property="pmd.failOnViolation", defaultValue="true", required=true) protected boolean failOnViolationWhether to fail the build if the validation check fails. The propertiesfailurePriority
andmaxAllowedViolations
control under which conditions exactly the build should be failed. -
aggregate
Deprecated.since 3.15.0 Use the goalpmd:aggregate-check
orpmd:aggregate-cpd-check
instead.Whether to build an aggregated report at the root, or build individual reports.- Since:
- 2.2
-
project
The project to analyze.
-
-
Constructor Details
-
AbstractPmdViolationCheckMojo
Initialize this abstact check mojo by giving the correct ExcludeFromFile helper.- Parameters:
excludeFromFile
- the needed helper, for the specific violation type
-
-
Method Details
-
executeCheck
protected void executeCheck(String filename, String tagName, String key, int failurePriority) throws MojoFailureException, MojoExecutionException -
getPriority
-
newViolationDetailsInstance
-
printErrors
Prints the warnings and failures- Parameters:
failures
- list of failureswarnings
- list of warnings
-
printError
Formats the failure details and prints them as an INFO message- 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 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
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
-
isFailOnViolation
public boolean isFailOnViolation() -
getMaxAllowedViolations
-
isAggregator
protected boolean isAggregator()
-
pmd:aggregate-check
orpmd:aggregate-cpd-check
instead.