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
public abstract class AbstractPmdViolationCheckMojo<D> extends AbstractMojo
Base class for mojos that check if there were any PMD violations.- Version:
- $Id$
- Author:
- Brett Porter
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
aggregate
Whether to build an aggregated report at the root, or build individual reports.protected boolean
failOnViolation
Whether to fail the build if the validation check fails.protected MavenProject
project
The project to analyze.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractPmdViolationCheckMojo(ExcludeFromFile<D> excludeFromFile)
Initialize this abstact check mojo by giving the correct ExcludeFromFile helper.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
executeCheck(java.lang.String filename, java.lang.String tagName, java.lang.String key, int failurePriority)
protected abstract java.util.List<D>
getErrorDetails(java.io.File analysisFile)
Gets the attributes and text for the violation tag and puts them in a HashMapjava.lang.Integer
getMaxAllowedViolations()
protected abstract int
getPriority(D errorDetail)
boolean
isFailOnViolation()
protected abstract ViolationDetails<D>
newViolationDetailsInstance()
protected abstract void
printError(D item, java.lang.String severity)
Formats the failure details and prints them as an INFO messageprotected void
printErrors(java.util.List<D> failures, java.util.List<D> warnings)
Prints the warnings and failures-
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
-
-
-
Field Detail
-
failOnViolation
@Parameter(property="pmd.failOnViolation", defaultValue="true", required=true) protected boolean failOnViolation
Whether to fail the build if the validation check fails. The propertiesfailurePriority
andmaxAllowedViolations
control under which conditions exactly the build should be failed.
-
aggregate
@Parameter(property="aggregate", defaultValue="false") protected boolean aggregate
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 MavenProject project
The project to analyze.
-
-
Constructor Detail
-
AbstractPmdViolationCheckMojo
protected AbstractPmdViolationCheckMojo(ExcludeFromFile<D> excludeFromFile)
Initialize this abstact check mojo by giving the correct ExcludeFromFile helper.- Parameters:
excludeFromFile
- the needed helper, for the specific violation type
-
-
Method Detail
-
executeCheck
protected void executeCheck(java.lang.String filename, java.lang.String tagName, java.lang.String key, int failurePriority) throws MojoFailureException, MojoExecutionException
-
getPriority
protected abstract int getPriority(D errorDetail)
-
newViolationDetailsInstance
protected abstract ViolationDetails<D> newViolationDetailsInstance()
-
printErrors
protected void printErrors(java.util.List<D> failures, java.util.List<D> warnings)
Prints the warnings and failures- Parameters:
failures
- list of failureswarnings
- list of warnings
-
printError
protected abstract void printError(D item, java.lang.String severity)
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 java.util.List<D> getErrorDetails(java.io.File analysisFile) throws XmlPullParserException, java.io.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:
XmlPullParserException
- if the analysis file contains invalid XMLjava.io.IOException
- if the analysis file could be read
-
isFailOnViolation
public boolean isFailOnViolation()
-
getMaxAllowedViolations
public java.lang.Integer getMaxAllowedViolations()
-
-