@Execute(phase=INSTALL,
goal="instrument",
lifecycle="clover")
@Mojo(name="instrument")
public class CloverInstrumentMojo
extends AbstractCloverInstrumentMojo
Fork a custom build lifecycle in which all sources will be instrumented by Clover and next execute this
lifecycle till the install phase. All instrumented classes will be stored in a separate directory. Similarly,
artifacts produced will have the 'clover' classifier.
This goal is forking a lifecycle because we don't want the Clover instrumentation to affect the main lifecycle
build. This will prevent instrumented sources to be put in production by error. Thus running
mvn install on a project where this instrument goal has been specified will run the
build twice: once for building the project as usual and another time for instrumenting the sources with Clover
and generating the Clover database.
Attention: Maven does not support multiple classifiers for an artifact. In case your project creates artifacts with classifiers, it may happen that the 'clover' classifier will be lost and an instrumented artifact will be installed as non-instrumented one.
Example: clover:instrument + jar:test-jar + install:install
[INFO] --- maven-jar-plugin:2.6:test-jar (default) @ moneybags ---
[INFO] Building jar: .../moneybags-1.0-SNAPSHOT-clover-tests.jar <<< file with double classifier was created
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ moneybags ---
[INFO] Installing .../moneybags-1.0-SNAPSHOT-clover-tests.jar to
~/.m2/.../moneybags-1.0-SNAPSHOT-tests.jar <<< but 'clover' classifier was lost
In order to avoid this, you can use the instrument-test goal, which runs a forked lifecycle till
the test phase.
cloveredArtifactExpiryInMillis, copyExcludedFiles, distributedCoverage, encoding, excludes, excludesFile, excludesList, flushPolicy, groverJar, includes, includesAllSourceRoots, includesFile, includesList, includesTestSourceRoots, instrumentation, jdk, methodContexts, methodWithMetricsContexts, repositoryPollutionProtection, scope, setTestFailureIgnore, skipGroverJar, staleMillis, statementContexts, testSources, useCloverClassifier, useFullyQualifiedJavaLangcloverOutputDirectory, debug, license, licenseLocation, skip, snapshot| Constructor and Description |
|---|
CloverInstrumentMojo() |
| Modifier and Type | Method and Description |
|---|---|
void |
execute() |
protected boolean |
shouldRedirectArtifacts() |
protected boolean |
shouldRedirectOutputDirectories() |
failIfCustomClassifierIsPresent, failIfDeployPhaseIsPresent, failIfInstallPhaseIsPresent, getDistributedCoverage, getEncoding, getExcludes, getFlushPolicy, getIncludes, getInstrumentation, getInstrumentLambda, getJdk, getMethodContexts, getMethodWithMetricsContexts, getStaleMillis, getStatementContexts, getTestSources, isCopyExcludedFiles, isIncludesAllSourceRoots, isUseFullyQualifiedJavaLangareCloverDatabasesAvailable, 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, resolveCloverDatabasepublic void execute()
throws org.apache.maven.plugin.MojoExecutionException
execute in interface org.apache.maven.plugin.Mojoexecute in class AbstractCloverInstrumentMojoorg.apache.maven.plugin.MojoExecutionExceptionAbstractCloverMojo.execute()protected boolean shouldRedirectArtifacts()
shouldRedirectArtifacts in class AbstractCloverInstrumentMojoprotected boolean shouldRedirectOutputDirectories()
shouldRedirectOutputDirectories in class AbstractCloverInstrumentMojoCopyright © 2019 OpenClover.org. All rights reserved.