Class JacocoTaskExtension
java.lang.Object
org.gradle.testing.jacoco.plugins.JacocoTaskExtension
Extension for tasks that should run with a Jacoco agent to generate coverage execution data.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The types of output that the agent can use for execution data. -
Constructor Summary
ConstructorDescriptionJacocoTaskExtension
(Project project, org.gradle.internal.jacoco.JacocoAgentJar agent, JavaForkOptions task) Creates a Jacoco task extension. -
Method Summary
Modifier and TypeMethodDescriptionIP address or hostname to use withJacocoTaskExtension.Output.TCP_SERVER
orJacocoTaskExtension.Output.TCP_CLIENT
.Gets all properties in the format expected of the agent JVM argument.Path to dump all class files the agent sees are dumped to.The path for the execution data to be written to.List of classloader names that should be excluded from analysis.List of class names that should be excluded from analysis.List of class names that should be included in analysis.The type of output to generate.int
getPort()
Port to bind to forJacocoTaskExtension.Output.TCP_SERVER
orJacocoTaskExtension.Output.TCP_CLIENT
.An identifier for the session written to the execution data.boolean
isAppend()
Whether or not data should be appended if thedestinationFile
already exists.boolean
Whether or not to dump the coverage data at VM shutdown.boolean
Whether or not the task should generate execution data.boolean
Whether or not classes without source location should be instrumented.boolean
isJmx()
Whether or not to expose functionality via JMX underorg.jacoco:type=Runtime
.void
setAddress
(String address) void
setAppend
(boolean append) void
setClassDumpDir
(File classDumpDir) Sets path to dump all class files the agent sees are dumped to.void
setDestinationFile
(File destinationFile) void
setDestinationFile
(Provider<File> destinationFile) Set the provider for calculating the destination file.void
setDumpOnExit
(boolean dumpOnExit) void
setEnabled
(boolean enabled) void
setExcludeClassLoaders
(List<String> excludeClassLoaders) void
setExcludes
(List<String> excludes) void
setIncludeNoLocationClasses
(boolean includeNoLocationClasses) void
setIncludes
(List<String> includes) void
setJmx
(boolean jmx) void
setOutput
(JacocoTaskExtension.Output output) void
setPort
(int port) void
setSessionId
(String sessionId)
-
Constructor Details
-
JacocoTaskExtension
public JacocoTaskExtension(Project project, org.gradle.internal.jacoco.JacocoAgentJar agent, JavaForkOptions task) Creates a Jacoco task extension.- Parameters:
project
- the projectagent
- the agent JAR to use for analysistask
- the task we extend
-
-
Method Details
-
isEnabled
public boolean isEnabled()Whether or not the task should generate execution data. Defaults totrue
. -
setEnabled
public void setEnabled(boolean enabled) -
getDestinationFile
The path for the execution data to be written to. -
setDestinationFile
Set the provider for calculating the destination file.- Parameters:
destinationFile
- Destination file provider- Since:
- 4.0
-
setDestinationFile
-
isAppend
public boolean isAppend()Whether or not data should be appended if thedestinationFile
already exists. Defaults totrue
. -
setAppend
public void setAppend(boolean append) -
getIncludes
List of class names that should be included in analysis. Names can use wildcards (* and ?). If left empty, all classes will be included. Defaults to an empty list. -
setIncludes
-
getExcludes
List of class names that should be excluded from analysis. Names can use wildcard (* and ?). Defaults to an empty list. -
setExcludes
-
getExcludeClassLoaders
List of classloader names that should be excluded from analysis. Names can use wildcards (* and ?). Defaults to an empty list. -
setExcludeClassLoaders
-
isIncludeNoLocationClasses
public boolean isIncludeNoLocationClasses()Whether or not classes without source location should be instrumented. Defaults tofalse
. This property is only taken into account if the used JaCoCo version supports this option (JaCoCo version >= 0.7.6) -
setIncludeNoLocationClasses
public void setIncludeNoLocationClasses(boolean includeNoLocationClasses) -
getSessionId
An identifier for the session written to the execution data. Defaults to an auto-generated identifier. -
setSessionId
-
isDumpOnExit
public boolean isDumpOnExit()Whether or not to dump the coverage data at VM shutdown. Defaults totrue
. -
setDumpOnExit
public void setDumpOnExit(boolean dumpOnExit) -
getOutput
The type of output to generate. Defaults toJacocoTaskExtension.Output.FILE
. -
setOutput
-
getAddress
IP address or hostname to use withJacocoTaskExtension.Output.TCP_SERVER
orJacocoTaskExtension.Output.TCP_CLIENT
. Defaults to localhost. -
setAddress
-
getPort
public int getPort()Port to bind to forJacocoTaskExtension.Output.TCP_SERVER
orJacocoTaskExtension.Output.TCP_CLIENT
. Defaults to 6300. -
setPort
public void setPort(int port) -
getClassDumpDir
Path to dump all class files the agent sees are dumped to. Defaults to no dumps.- Since:
- 3.4
-
setClassDumpDir
Sets path to dump all class files the agent sees are dumped to. Defaults to no dumps.- Since:
- 3.4
-
isJmx
public boolean isJmx()Whether or not to expose functionality via JMX underorg.jacoco:type=Runtime
. Defaults tofalse
. The configuration of the jmx property is only taken into account if the used JaCoCo version supports this option (JaCoCo version >= 0.6.2) -
setJmx
public void setJmx(boolean jmx) -
getAsJvmArg
Gets all properties in the format expected of the agent JVM argument.- Returns:
- state of extension in a JVM argument
-