public abstract class AbstractCloverInstrumentMojo extends AbstractCloverMojo implements CompilerConfiguration
| Modifier and Type | Field and Description |
|---|---|
protected long |
cloveredArtifactExpiryInMillis
The difference (in milliseconds) that a -clover classified artifact can have to a non-clover classified artifact.
|
protected boolean |
copyExcludedFiles
If set, then the clover-maven-plugin will not copy files that were excluded, across to the target/clover directory.
|
protected DistributedCoverage |
distributedCoverage
The configuration for distributed coverage collection by Clover.
|
protected String |
encoding
The character encoding to use when parsing source files.
|
protected Set<String> |
excludes
The list of file to exclude from the instrumentation.
|
protected String |
excludesFile
The file containing a list of file paths, separated by new line, to exclude from the instrumentation.
|
protected String |
excludesList
The comma seperated list of file to exclude from the instrumentation.
|
protected String |
flushPolicy
The Clover flush policy to use.
|
protected File |
groverJar
By default, Clover Maven Plugin generates the
${java.io.tmpdir}/grover*.jar file during setup,
which is next being added as the dependent artifact to the build. |
protected Set<String> |
includes
The list of file to include in the instrumentation.
|
protected boolean |
includesAllSourceRoots
Till 3.1.11: whether the Clover plugin should instrument all source roots (for example
src/main/java, src/main/groovy, target/generated-sources, so including the generated sources)
or whether it should only instrument the main source root (usually src/main/java). |
protected String |
includesFile
The file containing a list of file paths, separated by new line, to include in the instrumentation.
|
protected String |
includesList
The comma seperated list of files to include in the instrumentation.
|
protected boolean |
includesTestSourceRoots
Whether the Clover plugin should instrument test source roots.
|
protected String |
instrumentation
The level to instrument to.
|
protected String |
jdk
Which Java language level Clover shall use to parse sources.
|
protected Map<String,String> |
methodContexts
Specifies the custom method contexts to use for filtering specific methods from Clover reports.
|
protected Set<MethodWithMetricsContext> |
methodWithMetricsContexts
Specifies the custom method contexts to use for filtering specific methods from Clover reports.
|
protected boolean |
repositoryPollutionProtection
Try to protect your build from installing instrumented artifacts into local ~/.m2 cache
or deploying them to a binaries repository.
|
protected String |
scope
When creating the clover.jar dependency, what scope to use.
|
protected boolean |
setTestFailureIgnore
If set to
true, Clover will add several properties to the build configuration which
disable a build failure for following plugins: |
protected boolean |
skipGroverJar
By default, Clover Maven Plugin generates the
${java.io.tmpdir}/grover*.jar file during setup,
which is next being added as the dependent artifact to the build. |
protected int |
staleMillis
Sets the granularity in milliseconds of the last modification date for testing whether a source needs reinstrumentation.
|
protected Map<String,String> |
statementContexts
Specifies the custom statement contexts to use for filtering specific statements from Clover reports.
|
protected TestSources |
testSources
Specifies a custom test detector configuration.
|
protected boolean |
useCloverClassifier
Whether or not to include the -clover classifier on artifacts.
|
protected boolean |
useFullyQualifiedJavaLang
Use the fully qualified package name for java.lang.* classes.
|
cloverOutputDirectory, debug, license, licenseLocation, skip, snapshot| Constructor and Description |
|---|
AbstractCloverInstrumentMojo() |
areCloverDatabasesAvailable, getCloverDatabase, getCloverMergeDatabase, getDescendantModuleProjects, getFlushInterval, getModuleProjects, getProject, getReactorProjects, getResourceAsFile, getWaitForFlush, isLastProjectInReactor, isModuleOfProject, isSingleCloverDatabase, registerCloverAntTasks, resolveCloverDatabase, setLicense, setLicenseLocation, setProject, waitForFlushgetLog, getPluginContext, setLog, setPluginContextclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetFlushIntervalgetCloverDatabase, getLog, getProject, getReactorProjects, isSingleCloverDatabase, resolveCloverDatabase@Parameter(property="maven.clover.cloveredArtifactExpiryInMillis",
defaultValue="2000")
protected long cloveredArtifactExpiryInMillis
The difference (in milliseconds) that a -clover classified artifact can have to a non-clover classified artifact.
If the -clover classified artifact is more than cloveredArtifactExpiryInMillis older than the non-clover classified artifact, then the non-classified artifact will be used.
This setting defaults to 2000.
@Parameter(property="maven.clover.copyExcludedFiles",
defaultValue="true")
protected boolean copyExcludedFiles
@Parameter protected DistributedCoverage distributedCoverage
The configuration for distributed coverage collection by Clover.
If present, default values will be used and coverage will be collected across JVMs.
Optional nested elements (and their defaults) of distributedCoverage are:
@Parameter(property="maven.clover.encoding") protected String encoding
@Parameter protected Set<String> excludes
@Parameter(property="maven.clover.excludesList") protected String excludesList
@Parameter(property="maven.clover.excludesFile") protected String excludesFile
excludes and excludesList@Parameter(property="maven.clover.flushPolicy",
defaultValue="threaded")
protected String flushPolicy
@Parameter(property="maven.clover.groverJar") protected File groverJar
By default, Clover Maven Plugin generates the ${java.io.tmpdir}/grover*.jar file during setup,
which is next being added as the dependent artifact to the build. As the file has generated, unique
name and the jar is not being removed at the end of the build, these files can litter the temporary
directory.
By setting this parameter you can:
a) specify constant file name for generated artifact,
b) choose location different than ${java.io.tmpdir}.
However, you must ensure that:
a) grover.jar will not be deleted till end of the build (for example don't put into ./target directory
and next run mvn clover:setup clean)
b) grover.jar will not be shared among builds with different Clover Maven Plugin versions used (for
example if ProjectA uses Clover v 3.1.8 and ProjectB uses Clover v 3.1.9 then they shall have different
groverJar locations defined)
@Parameter protected Set<String> includes
@Parameter(property="maven.clover.includesList") protected String includesList
@Parameter(property="maven.clover.includesFile") protected String includesFile
includes and includesList@Parameter(property="maven.clover.includesAllSourceRoots",
defaultValue="false")
protected boolean includesAllSourceRoots
Till 3.1.11: whether the Clover plugin should instrument all source roots (for example
src/main/java, src/main/groovy, target/generated-sources, so including the generated sources)
or whether it should only instrument the main source root (usually src/main/java).
Since 3.1.12: whether the Clover plugin should instrument all source roots (for example
src/main/java, src/main/groovy, target/generated-sources, so including the generated sources)
or whether it should instrument non-generated source roots (i.e. all roots except target/generated-sources/*)
@Parameter(property="maven.clover.includesTestSourceRoots",
defaultValue="true")
protected boolean includesTestSourceRoots
@Parameter(property="maven.clover.instrumentation",
defaultValue="statement")
protected String instrumentation
The level to instrument to. Valid values are 'method' or 'statement'. Default is 'statement'.
Setting this to 'method' greatly reduces the overhead of enabling Clover, however limited or no reporting is available. The current use of setting this to method is for Test Optimization only.
@Parameter(property="maven.clover.jdk") protected String jdk
Which Java language level Clover shall use to parse sources. Valid values are:
By default Clover instruments using the highest language level supported.
@Parameter protected Map<String,String> methodContexts
Specifies the custom method contexts to use for filtering specific methods from Clover reports.
e.g.<main>public static void main\(String args\[\]\).*</main>
will define the context called 'main' which will match all public static void main methods.
@Parameter protected Set<MethodWithMetricsContext> methodWithMetricsContexts
Specifies the custom method contexts to use for filtering specific methods from Clover reports. This is more detailed format compared to methodContexts, which allows to set also code metrics to be matched. Example:
<methodWithMetricsContexts>
<methodWithMetricsContext>
<name>simpleGetter</name> <!-- (mandatory) -->
<regexp>public .* get.*\(\)</regexp> <!-- (mandatory) -->
<maxComplexity>1</maxComplexity> <!-- at most 1 cycle (optional) -->
<maxStatements>1</maxStatements> <!-- at most 1 statement (optional) -->
<maxAggregatedComplexity>2</maxAggregatedComplexity> <!-- no more than 2 cycles including inline classes (optional) -->
<maxAggregatedStatements>10</maxAggregatedStatements> <!-- no more than 10 statements including inline classes (optional) -->
</methodWithMetricsContext>
<!-- can add more methodWithMetricsContext -->
</methodWithMetricsContexts>
will define a context called 'simpleGetter' which matches all public getXyz() methods containing at most one statement; this statement may contain more complex logic (an anonymous inline class) but not bigger than 9 statements.
@Parameter(property="maven.clover.repositoryPollutionProtection",
defaultValue="false")
protected boolean repositoryPollutionProtection
Try to protect your build from installing instrumented artifacts into local ~/.m2 cache or deploying them to a binaries repository. If this option is enabled, Clover will fail a build whenever it detects that 'install' or 'deploy' phase is about to be called. It will also fail a build if it detects that an artifact having multiple classifiers (e.g. "-clover-tests.jar"), which are not supported by Maven, is about to be installed under original name (e.g. "-tests.jar").
Please note that this flag may not protect from all possible cases.
@Parameter(property="maven.clover.scope") protected String scope
@Parameter(property="maven.clover.setTestFailureIgnore",
defaultValue="false")
protected boolean setTestFailureIgnore
If set to true, Clover will add several properties to the build configuration which
disable a build failure for following plugins:
Thanks to this, build continues despite test failures or code validation failures and thus it is possible to generate a Clover coverage report for failed tests at the end of the build.
Note: before version 3.1.9 the testFailureIgnore property was set to true for the forked Clover lifecycle ('instrument' goal) for 'test' and 'integration-test' phases. Since 3.1.9 it is no longer set.
@Parameter(property="maven.clover.skipGroverJar",
defaultValue="false")
protected boolean skipGroverJar
By default, Clover Maven Plugin generates the ${java.io.tmpdir}/grover*.jar file during setup,
which is next being added as the dependent artifact to the build. As the file has generated, unique
name and the jar is not being removed at the end of the build, these files can litter the temporary
directory.
In case when there is no Groovy code in the project, this parameter can be set to true in order
to disable generation of grover.jar artifact.
@Parameter protected Map<String,String> statementContexts
<log>^LOG\..*</log>defines a statement context called "log" which matches all LOG statements.
@Parameter(property="maven.clover.staleMillis",
defaultValue="0")
protected int staleMillis
@Parameter protected TestSources testSources
<testSources>
<includes>
<include>**/*</include>
<include>*WebTest.java</include>
<include>**/*IT.java</include>
</includes>
<excludes>
<exclude>deprecated/**</exclude>
</excludes>
<testClasses>
<testClass> <!-- 0..N occurrences -->
<name>.*Test</name>
<super>WebTest</super>
<annotation>@Repeat</annotation>
<package>org\.openclover\..*</package>
<tag>@chrome</tag>
<testMethods> <!-- 0..N occurrences -->
<testMethod>
<name>check.*</name>
<annotation>@Test</annotation>
<tag>@web</tag>
<returnType>void</returnType>
</testMethod>
</testMethods>
</testClass>
</testClasses>
</testSources>
Note: every tag is optional.@Parameter(property="maven.clover.useCloverClassifier",
defaultValue="true")
protected boolean useCloverClassifier
@Parameter(property="maven.clover.useFullyQualifiedJavaLang",
defaultValue="true")
protected boolean useFullyQualifiedJavaLang
public void execute()
throws org.apache.maven.plugin.MojoExecutionException
AbstractCloverMojoexecute in interface org.apache.maven.plugin.Mojoexecute in class AbstractCloverMojoorg.apache.maven.plugin.MojoExecutionExceptionMojo.execute()protected abstract boolean shouldRedirectArtifacts()
protected abstract boolean shouldRedirectOutputDirectories()
public boolean isCopyExcludedFiles()
isCopyExcludedFiles in interface CompilerConfigurationpublic String getEncoding()
getEncoding in interface CompilerConfigurationpublic DistributedCoverage getDistributedCoverage()
getDistributedCoverage in interface CompilerConfigurationpublic Set<String> getExcludes()
getExcludes in interface CompilerConfigurationpublic String getFlushPolicy()
getFlushPolicy in interface CompilerConfigurationpublic Set<String> getIncludes()
getIncludes in interface CompilerConfigurationpublic String getInstrumentation()
getInstrumentation in interface CompilerConfigurationpublic String getInstrumentLambda()
getInstrumentLambda in interface CompilerConfigurationpublic String getJdk()
getJdk in interface CompilerConfigurationpublic Map<String,String> getMethodContexts()
getMethodContexts in interface CompilerConfigurationpublic Set<MethodWithMetricsContext> getMethodWithMetricsContexts()
getMethodWithMetricsContexts in interface CompilerConfigurationpublic Map<String,String> getStatementContexts()
getStatementContexts in interface CompilerConfigurationpublic int getStaleMillis()
getStaleMillis in interface CompilerConfigurationpublic boolean isIncludesAllSourceRoots()
isIncludesAllSourceRoots in interface CompilerConfigurationpublic boolean isUseFullyQualifiedJavaLang()
isUseFullyQualifiedJavaLang in interface CompilerConfigurationpublic TestSources getTestSources()
getTestSources in interface CompilerConfigurationprotected void failIfInstallPhaseIsPresent(BuildLifecycleAnalyzer lifecycleAnalyzer) throws org.apache.maven.plugin.MojoExecutionException
lifecycleAnalyzer - analyserorg.apache.maven.plugin.MojoExecutionException - if 'install' phase is presentprotected void failIfDeployPhaseIsPresent(BuildLifecycleAnalyzer lifecycleAnalyzer) throws org.apache.maven.plugin.MojoExecutionException
lifecycleAnalyzer - analyserorg.apache.maven.plugin.MojoExecutionException - if 'deploy' phase is presentprotected void failIfCustomClassifierIsPresent()
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException - if custom classifier is presentCopyright © 2019 OpenClover.org. All rights reserved.