Class CheckMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
,IViolationsOutput
- Since:
- 0.6.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final String
private File
File with execution data.A list of class files to exclude from analysis.private boolean
Halt the build if any of the checks fail.A list of class files to include into analysis.private static final String
private List
<RuleConfiguration> Check configuration used to specify rules on element types (BUNDLE, PACKAGE, CLASS, SOURCEFILE or METHOD) with a list of limits.private boolean
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
private void
void
Executes Mojo.void
onViolation
(ICoverageNode node, Rule rule, Limit limit, String message) Called for every rule violation.Methods inherited from class org.jacoco.maven.AbstractJacocoMojo
execute, getProject, skipMojo
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
MSG_SKIPPING
- See Also:
-
CHECK_SUCCESS
- See Also:
-
CHECK_FAILED
- See Also:
-
rules
Check configuration used to specify rules on element types (BUNDLE, PACKAGE, CLASS, SOURCEFILE or METHOD) with a list of limits. Each limit applies to a certain counter (INSTRUCTION, LINE, BRANCH, COMPLEXITY, METHOD, CLASS) and defines a minimum or maximum for the corresponding value (TOTALCOUNT, COVEREDCOUNT, MISSEDCOUNT, COVEREDRATIO, MISSEDRATIO). If a limit refers to a ratio it must be in the range from 0.0 to 1.0 where the number of decimal places will also determine the precision in error messages. A limit ratio may optionally be declared as a percentage where 0.80 and 80% represent the same value.
If not specified the following defaults are assumed:
- rule element: BUNDLE
- limit counter: INSTRUCTION
- limit value: COVEREDRATIO
This example requires an overall instruction coverage of 80% and no class must be missed:
<rules> <rule> <element>BUNDLE</element> <limits> <limit> <counter>INSTRUCTION</counter> <value>COVEREDRATIO</value> <minimum>0.80</minimum> </limit> <limit> <counter>CLASS</counter> <value>MISSEDCOUNT</value> <maximum>0</maximum> </limit> </limits> </rule> </rules>
This example requires a line coverage minimum of 50% for every class except test classes:
<rules> <rule> <element>CLASS</element> <excludes> <exclude>*Test</exclude> </excludes> <limits> <limit> <counter>LINE</counter> <value>COVEREDRATIO</value> <minimum>50%</minimum> </limit> </limits> </rule> </rules>
-
haltOnFailure
@Parameter(property="jacoco.haltOnFailure", defaultValue="true", required=true) private boolean haltOnFailureHalt the build if any of the checks fail. -
dataFile
File with execution data. -
includes
A list of class files to include into analysis. May use wildcard characters (* and ?). When not specified everything will be included. -
excludes
A list of class files to exclude from analysis. May use wildcard characters (* and ?). When not specified nothing will be excluded. -
violations
private boolean violations
-
-
Constructor Details
-
CheckMojo
public CheckMojo()
-
-
Method Details
-
canCheckCoverage
private boolean canCheckCoverage() -
executeMojo
public void executeMojo() throws org.apache.maven.plugin.MojoExecutionExceptionDescription copied from class:AbstractJacocoMojo
Executes Mojo.- Specified by:
executeMojo
in classAbstractJacocoMojo
- Throws:
org.apache.maven.plugin.MojoExecutionException
- if an unexpected problem occurs. Throwing this exception causes a "BUILD ERROR" message to be displayed.
-
executeCheck
private void executeCheck() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
onViolation
Description copied from interface:IViolationsOutput
Called for every rule violation.- Specified by:
onViolation
in interfaceIViolationsOutput
- Parameters:
node
- node which violates a rulerule
- rule which is violatedlimit
- limit which is violatedmessage
- readable message describing this violation
-