# Class JacocoTaskExtension

java.lang.Object
org.gradle.testing.jacoco.plugins.JacocoTaskExtension

public abstract class JacocoTaskExtension extends Object
Extension for tasks that should run with a Jacoco agent to generate coverage execution data.

Since:
  1.6

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `JacocoTaskExtension.Output`
  The 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

  Modifier and Type
  Method
  Description
  `@Nullable String`
  `getAddress()`
  IP address or hostname to use with `JacocoTaskExtension.Output.TCP_SERVER` or `JacocoTaskExtension.Output.TCP_CLIENT`.
  `FileCollection`
  `getAgentClasspath()`
  The Jacoco agent classpath.
  `String`
  `getAsJvmArg()`
  Gets all properties in the format expected of the agent JVM argument.
  `@Nullable File`
  `getClassDumpDir()`
  Path to dump all class files the agent sees are dumped to.
  `abstract DirectoryProperty`
  `getClassDumpDirectory()`
  Path to dump all class files the agent sees are dumped to.
  `@Nullable File`
  `getDestinationFile()`
  The path for the execution data to be written to.
  `@Nullable List<String>`
  `getExcludeClassLoaders()`
  List of classloader names that should be excluded from analysis.
  `@Nullable List<String>`
  `getExcludes()`
  List of class names that should be excluded from analysis.
  `@Nullable List<String>`
  `getIncludes()`
  List of class names that should be included in analysis.
  `JacocoTaskExtension.Output`
  `getOutput()`
  The type of output to generate.
  `int`
  `getPort()`
  Port to bind to for `JacocoTaskExtension.Output.TCP_SERVER` or `JacocoTaskExtension.Output.TCP_CLIENT`.
  `@Nullable String`
  `getSessionId()`
  An identifier for the session written to the execution data.
  `boolean`
  `isDumpOnExit()`
  Whether or not to dump the coverage data at VM shutdown.
  `boolean`
  `isEnabled()`
  Whether or not the task should generate execution data.
  `boolean`
  `isIncludeNoLocationClasses()`
  Whether or not classes without source location should be instrumented.
  `boolean`
  `isJmx()`
  Whether or not to expose functionality via JMX under `org.jacoco:type=Runtime`.
  `void`
  `setAddress(@Nullable String address)`
  Sets the address.
  `void`
  `setClassDumpDir(@Nullable File classDumpDir)`
  Sets path to dump all class files the agent sees are dumped to.
  `void`
  `setDestinationFile(@Nullable File destinationFile)`
  Sets the destination file.
  `void`
  `setDestinationFile(Provider<File> destinationFile)`
  Set the provider for calculating the destination file.
  `void`
  `setDumpOnExit(boolean dumpOnExit)`
  Sets the dump on exit.
  `void`
  `setEnabled(boolean enabled)`
  Sets the enabled.
  `void`
  `setExcludeClassLoaders(@Nullable List<String> excludeClassLoaders)`
  Sets the exclude class loaders.
  `void`
  `setExcludes(@Nullable List<String> excludes)`
  Sets the excludes.
  `void`
  `setIncludeNoLocationClasses(boolean includeNoLocationClasses)`
  Sets the include no location classes.
  `void`
  `setIncludes(@Nullable List<String> includes)`
  Sets the includes.
  `void`
  `setJmx(boolean jmx)`
  Sets the jmx.
  `void`
  `setOutput(JacocoTaskExtension.Output output)`
  Sets the output.
  `void`
  `setPort(int port)`
  Sets the port.
  `void`
  `setSessionId(@Nullable String sessionId)`
  Sets the session id.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### JacocoTaskExtension

    @Inject public JacocoTaskExtension(ObjectFactory objects, org.gradle.internal.jacoco.JacocoAgentJar agent, JavaForkOptions task)
    Creates a Jacoco task extension.
    Parameters:
      `objects` - the object factory
      `agent` - the agent JAR to use for analysis
      `task` - the task we extend

- ## Method Details

  - ### isEnabled

    @Input public boolean isEnabled()
    Whether or not the task should generate execution data. Defaults to `true`.
    Since:
      1.6

  - ### setEnabled

    public void setEnabled(boolean enabled)
    Sets the enabled.
    Since:
      1.6

  - ### getDestinationFile

    @Optional @OutputFile public @Nullable File getDestinationFile()
    The path for the execution data to be written to.
    Since:
      1.7

  - ### setDestinationFile

    public void setDestinationFile(Provider<File> destinationFile)
    Set the provider for calculating the destination file.
    Parameters:
      `destinationFile` - Destination file provider
    Since:
      4.0

  - ### setDestinationFile

    public void setDestinationFile(@Nullable File destinationFile)
    Sets the destination file.
    Since:
      1.7

  - ### getIncludes

    @Optional @Input public @Nullable List<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.
    Since:
      1.6

  - ### setIncludes

    public void setIncludes(@Nullable List<String> includes)
    Sets the includes.
    Since:
      1.6

  - ### getExcludes

    @Optional @Input public @Nullable List<String> getExcludes()
    List of class names that should be excluded from analysis. Names can use wildcard (* and ?). Defaults to an empty list.
    Since:
      1.6

  - ### setExcludes

    public void setExcludes(@Nullable List<String> excludes)
    Sets the excludes.
    Since:
      1.6

  - ### getExcludeClassLoaders

    @Optional @Input public @Nullable List<String> getExcludeClassLoaders()
    List of classloader names that should be excluded from analysis. Names can use wildcards (* and ?). Defaults to an empty list.
    Since:
      1.6

  - ### setExcludeClassLoaders

    public void setExcludeClassLoaders(@Nullable List<String> excludeClassLoaders)
    Sets the exclude class loaders.
    Since:
      1.6

  - ### isIncludeNoLocationClasses

    @Input public boolean isIncludeNoLocationClasses()
    Whether or not classes without source location should be instrumented. Defaults to `false`. This property is only taken into account if the used JaCoCo version supports this option (JaCoCo version >= 0.7.6)
    Since:
      2.13

  - ### setIncludeNoLocationClasses

    public void setIncludeNoLocationClasses(boolean includeNoLocationClasses)
    Sets the include no location classes.
    Since:
      2.13

  - ### getSessionId

    @Optional @Input public @Nullable String getSessionId()
    An identifier for the session written to the execution data. Defaults to an auto-generated identifier.
    Since:
      1.6

  - ### setSessionId

    public void setSessionId(@Nullable String sessionId)
    Sets the session id.
    Since:
      1.6

  - ### isDumpOnExit

    @Input public boolean isDumpOnExit()
    Whether or not to dump the coverage data at VM shutdown. Defaults to `true`.
    Since:
      1.6

  - ### setDumpOnExit

    public void setDumpOnExit(boolean dumpOnExit)
    Sets the dump on exit.
    Since:
      1.6

  - ### getOutput

    @Input public JacocoTaskExtension.Output getOutput()
    The type of output to generate. Defaults to `JacocoTaskExtension.Output.FILE`.
    Since:
      1.6

  - ### setOutput

    public void setOutput(JacocoTaskExtension.Output output)
    Sets the output.
    Since:
      1.6

  - ### getAddress

    @Optional @Input public @Nullable String getAddress()
    IP address or hostname to use with `JacocoTaskExtension.Output.TCP_SERVER` or `JacocoTaskExtension.Output.TCP_CLIENT`. Defaults to localhost.
    Since:
      1.6

  - ### setAddress

    public void setAddress(@Nullable String address)
    Sets the address.
    Since:
      1.6

  - ### getPort

    @Input public int getPort()
    Port to bind to for `JacocoTaskExtension.Output.TCP_SERVER` or `JacocoTaskExtension.Output.TCP_CLIENT`. Defaults to 6300.
    Since:
      1.6

  - ### setPort

    public void setPort(int port)
    Sets the port.
    Since:
      1.6

  - ### getClassDumpDirectory

    @Incubating @Optional @LocalState public abstract DirectoryProperty getClassDumpDirectory()
    Path to dump all class files the agent sees are dumped to. Defaults to no dumps.
    Since:
      9.7.0

  - ### getClassDumpDir

    @ReplacedBy("classDumpDirectory") public @Nullable 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 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 under `org.jacoco:type=Runtime`. Defaults to `false`. The configuration of the jmx property is only taken into account if the used JaCoCo version supports this option (JaCoCo version >= 0.6.2)
    Since:
      1.6

  - ### setJmx

    public void setJmx(boolean jmx)
    Sets the jmx.
    Since:
      1.6

  - ### getAgentClasspath

    @Classpath public FileCollection getAgentClasspath()
    The Jacoco agent classpath. This contains only one file - the agent jar.
    Since:
      4.6

  - ### getAsJvmArg

    @Internal public String getAsJvmArg()
    Gets all properties in the format expected of the agent JVM argument.
    Returns:
      state of extension in a JVM argument
    Since:
      1.6