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
Nested ClassesModifier and TypeClassDescription(package private) static classstatic enumThe types of output that the agent can use for execution data. -
Constructor Summary
ConstructorsConstructorDescriptionJacocoTaskExtension(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_SERVERorJacocoTaskExtension.Output.TCP_CLIENT.The Jacoco agent classpath.Gets all properties in the format expected of the agent JVM argument.@Nullable FilePath to dump all class files the agent sees are dumped to.abstract DirectoryPropertyPath to dump all class files the agent sees are dumped to.abstract RegularFilePropertyThe path for execution data to be written to.protected @Nullable FileDeprecated.Whether or not to dump the coverage data at VM shutdown.Whether or not the task should generate execution data.abstract ListProperty<String> List of classloader names that should be excluded from analysis.abstract ListProperty<String> List of class names that should be excluded from analysis.Whether or not classes without source location should be instrumented.abstract ListProperty<String> List of class names that should be included in analysis.getIsJmx()getJmx()Whether or not to expose functionality via JMX underorg.jacoco:type=Runtime.abstract Property<JacocoTaskExtension.Output> The type of output to generate.getPort()Port to bind to forJacocoTaskExtension.Output.TCP_SERVERorJacocoTaskExtension.Output.TCP_CLIENT.An identifier for the session written to the execution data.voidsetAddress(@Nullable String address) voidsetClassDumpDir(@Nullable File classDumpDir) Sets path to dump all class files the agent sees are dumped to.voidsetDestinationFile(@Nullable File destinationFile) voidsetDumpOnExit(boolean dumpOnExit) voidsetEnabled(boolean enabled) voidsetExcludeClassLoaders(@Nullable List<String> excludeClassLoaders) voidsetExcludes(@Nullable List<String> excludes) voidsetIncludeNoLocationClasses(boolean includeNoLocationClasses) voidsetIncludes(@Nullable List<String> includes) voidsetJmx(boolean jmx) voidsetOutput(JacocoTaskExtension.Output output) voidsetPort(int port) voidsetSessionId(@Nullable String sessionId)
-
Constructor Details
-
JacocoTaskExtension
@Inject public JacocoTaskExtension(org.gradle.internal.jacoco.JacocoAgentJar agent, JavaForkOptions task) Creates a Jacoco task extension.- Parameters:
agent- the agent JAR to use for analysistask- the task we extend
-
-
Method Details
-
getEnabled
Whether or not the task should generate execution data. Defaults totrue. -
getIsEnabled
-
setEnabled
public void setEnabled(boolean enabled) -
getDestinationFile
The path for execution data to be written to.- Returns:
- destination file for execution data output
- Since:
- 4.0
-
getDestinationFileOutput
Deprecated.This method exists becausegetDestinationFile()cannot be annotated with@OutputFiledirectly, as it cannot carry a task dependency and produces: Property 'destinationFile' is declared as an output property of an object with type JacocoTaskExtension but does not have a task associated with it.- Returns:
- the destination directory as a file
- Since:
- 9.7.0
-
setDestinationFile
-
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
-
getIncludeNoLocationClasses
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) -
getIsIncludeNoLocationClasses
-
setIncludeNoLocationClasses
public void setIncludeNoLocationClasses(boolean includeNoLocationClasses) -
getSessionId
An identifier for the session written to the execution data. Defaults to an auto-generated identifier. -
setSessionId
-
getDumpOnExit
Whether or not to dump the coverage data at VM shutdown. Defaults totrue. -
getIsDumpOnExit
-
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_SERVERorJacocoTaskExtension.Output.TCP_CLIENT. Defaults to localhost. -
setAddress
-
getPort
Port to bind to forJacocoTaskExtension.Output.TCP_SERVERorJacocoTaskExtension.Output.TCP_CLIENT. Defaults to 6300. -
setPort
public void setPort(int port) -
getClassDumpDirectory
Path to dump all class files the agent sees are dumped to. Defaults to no dumps.- Since:
- 9.7.0
-
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
-
getJmx
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) -
getIsJmx
-
setJmx
public void setJmx(boolean jmx) -
getAgentClasspath
The Jacoco agent classpath. This contains only one file - the agent jar.- Since:
- 4.6
-
getAsJvmArg
Gets all properties in the format expected of the agent JVM argument.- Returns:
- state of extension in a JVM argument
-