Class JacocoTaskExtension
- java.lang.Object
-
- org.gradle.testing.jacoco.plugins.JacocoTaskExtension
-
public abstract class JacocoTaskExtension extends java.lang.ObjectExtension for tasks that should run with a Jacoco agent to generate coverage execution data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJacocoTaskExtension.OutputThe types of output that the agent can use for execution data.
-
Constructor Summary
Constructors Constructor Description JacocoTaskExtension(ObjectFactory objects, org.gradle.internal.jacoco.JacocoAgentJar agent, JavaForkOptions task)Creates a Jacoco task extension.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetAddress()IP address or hostname to use withJacocoTaskExtension.Output.TCP_SERVERorJacocoTaskExtension.Output.TCP_CLIENT.FileCollectiongetAgentClasspath()The Jacoco agent classpath.java.lang.StringgetAsJvmArg()Gets all properties in the format expected of the agent JVM argument.java.io.FilegetClassDumpDir()Path to dump all class files the agent sees are dumped to.java.io.FilegetDestinationFile()The path for the execution data to be written to.java.util.List<java.lang.String>getExcludeClassLoaders()List of classloader names that should be excluded from analysis.java.util.List<java.lang.String>getExcludes()List of class names that should be excluded from analysis.java.util.List<java.lang.String>getIncludes()List of class names that should be included in analysis.JacocoTaskExtension.OutputgetOutput()The type of output to generate.intgetPort()Port to bind to forJacocoTaskExtension.Output.TCP_SERVERorJacocoTaskExtension.Output.TCP_CLIENT.java.lang.StringgetSessionId()An identifier for the session written to the execution data.booleanisDumpOnExit()Whether or not to dump the coverage data at VM shutdown.booleanisEnabled()Whether or not the task should generate execution data.booleanisIncludeNoLocationClasses()Whether or not classes without source location should be instrumented.booleanisJmx()Whether or not to expose functionality via JMX underorg.jacoco:type=Runtime.voidsetAddress(java.lang.String address)voidsetClassDumpDir(java.io.File classDumpDir)Sets path to dump all class files the agent sees are dumped to.voidsetDestinationFile(java.io.File destinationFile)voidsetDestinationFile(Provider<java.io.File> destinationFile)Set the provider for calculating the destination file.voidsetDumpOnExit(boolean dumpOnExit)voidsetEnabled(boolean enabled)voidsetExcludeClassLoaders(java.util.List<java.lang.String> excludeClassLoaders)voidsetExcludes(java.util.List<java.lang.String> excludes)voidsetIncludeNoLocationClasses(boolean includeNoLocationClasses)voidsetIncludes(java.util.List<java.lang.String> includes)voidsetJmx(boolean jmx)voidsetOutput(JacocoTaskExtension.Output output)voidsetPort(int port)voidsetSessionId(java.lang.String sessionId)
-
-
-
Constructor Detail
-
JacocoTaskExtension
@Inject public JacocoTaskExtension(ObjectFactory objects, org.gradle.internal.jacoco.JacocoAgentJar agent, JavaForkOptions task)
Creates a Jacoco task extension.- Parameters:
objects- the object factoryagent- the agent JAR to use for analysistask- the task we extend
-
-
Method Detail
-
isEnabled
@Input public boolean isEnabled()
Whether or not the task should generate execution data. Defaults totrue.
-
setEnabled
public void setEnabled(boolean enabled)
-
getDestinationFile
@Nullable @Optional @OutputFile public java.io.File getDestinationFile()
The path for the execution data to be written to.
-
setDestinationFile
public void setDestinationFile(Provider<java.io.File> destinationFile)
Set the provider for calculating the destination file.- Parameters:
destinationFile- Destination file provider- Since:
- 4.0
-
setDestinationFile
public void setDestinationFile(java.io.File destinationFile)
-
getIncludes
@Nullable @Optional @Input public java.util.List<java.lang.String> 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
public void setIncludes(@Nullable java.util.List<java.lang.String> includes)
-
getExcludes
@Nullable @Optional @Input public java.util.List<java.lang.String> getExcludes()
List of class names that should be excluded from analysis. Names can use wildcard (* and ?). Defaults to an empty list.
-
setExcludes
public void setExcludes(@Nullable java.util.List<java.lang.String> excludes)
-
getExcludeClassLoaders
@Nullable @Optional @Input public java.util.List<java.lang.String> getExcludeClassLoaders()
List of classloader names that should be excluded from analysis. Names can use wildcards (* and ?). Defaults to an empty list.
-
setExcludeClassLoaders
public void setExcludeClassLoaders(@Nullable java.util.List<java.lang.String> excludeClassLoaders)
-
isIncludeNoLocationClasses
@Input 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
@Nullable @Optional @Input public java.lang.String getSessionId()
An identifier for the session written to the execution data. Defaults to an auto-generated identifier.
-
setSessionId
public void setSessionId(@Nullable java.lang.String sessionId)
-
isDumpOnExit
@Input public boolean isDumpOnExit()
Whether or not to dump the coverage data at VM shutdown. Defaults totrue.
-
setDumpOnExit
public void setDumpOnExit(boolean dumpOnExit)
-
getOutput
@Input public JacocoTaskExtension.Output getOutput()
The type of output to generate. Defaults toJacocoTaskExtension.Output.FILE.
-
setOutput
public void setOutput(JacocoTaskExtension.Output output)
-
getAddress
@Nullable @Optional @Input public java.lang.String getAddress()
IP address or hostname to use withJacocoTaskExtension.Output.TCP_SERVERorJacocoTaskExtension.Output.TCP_CLIENT. Defaults to localhost.
-
setAddress
public void setAddress(@Nullable java.lang.String address)
-
getPort
@Input public int getPort()
Port to bind to forJacocoTaskExtension.Output.TCP_SERVERorJacocoTaskExtension.Output.TCP_CLIENT. Defaults to 6300.
-
setPort
public void setPort(int port)
-
getClassDumpDir
@Nullable @Optional @LocalState public java.io.File getClassDumpDir()
Path to dump all class files the agent sees are dumped to. Defaults to no dumps.- Since:
- 3.4
-
setClassDumpDir
public void setClassDumpDir(@Nullable java.io.File classDumpDir)Sets path to dump all class files the agent sees are dumped to. Defaults to no dumps.- Since:
- 3.4
-
isJmx
@Input 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)
-
getAgentClasspath
@Classpath public FileCollection getAgentClasspath()
The Jacoco agent classpath. This contains only one file - the agent jar.- Since:
- 4.6
-
getAsJvmArg
@Internal public java.lang.String getAsJvmArg()
Gets all properties in the format expected of the agent JVM argument.- Returns:
- state of extension in a JVM argument
-
-