Class AgentMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.jacoco.maven.AbstractJacocoMojo
-
- org.jacoco.maven.AbstractAgentMojo
-
- org.jacoco.maven.AgentMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(name="prepare-agent", defaultPhase=INITIALIZE, requiresDependencyResolution=RUNTIME, threadSafe=true) public class AgentMojo extends AbstractAgentMojo
Prepares a property pointing to the JaCoCo runtime agent that can be passed as a VM argument to the application under test. Depending on the project packaging type by default a property with the following name is set:
- tycho.testArgLine for packaging type eclipse-test-plugin and
- argLine otherwise.
If your project already defines VM arguments for test execution, be sure that they will include property defined by JaCoCo.
One of the ways to do this in case of maven-surefire-plugin - is to use syntax for late property evaluation:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <argLine>@{argLine} -your -extra -arguments</argLine> </configuration> </plugin>
You can define empty property to avoid JVM startup error
Could not find or load main class @{argLine}
when using late property evaluation and jacoco-maven-plugin not executed.Another way is to define "argLine" as a Maven property rather than as part of the configuration of maven-surefire-plugin:
<properties> <argLine>-your -extra -arguments</argLine> </properties> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <!-- no argLine here --> </configuration> </plugin>
Resulting coverage information is collected during execution and by default written to a file when the process terminates.
- Since:
- 0.5.3
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.File
destFile
Path to the output file for execution data.-
Fields inherited from class org.jacoco.maven.AbstractAgentMojo
address, AGENT_ARTIFACT_NAME, append, classDumpDir, dumpOnExit, exclClassLoaders, inclBootstrapClasses, inclNoLocationClasses, jmx, output, pluginArtifactMap, port, propertyName, sessionId, SUREFIRE_ARG_LINE, TYCHO_ARG_LINE
-
-
Constructor Summary
Constructors Constructor Description AgentMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) java.io.File
getDestFile()
-
Methods inherited from class org.jacoco.maven.AbstractAgentMojo
createAgentOptions, executeMojo, getAgentJarFile, getEffectivePropertyName, isEclipseTestPluginPackaging, isPropertyNameSpecified, skipMojo
-
Methods inherited from class org.jacoco.maven.AbstractJacocoMojo
execute, getProject
-
-
-
-
Method Detail
-
getDestFile
java.io.File getDestFile()
- Specified by:
getDestFile
in classAbstractAgentMojo
- Returns:
- the destFile
-
-