Package org.gradle.testing.jacoco.plugins

# 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.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `(package private) static class`
  `JacocoTaskExtension.DestinationFileAdapter`
  `static enum`
  `JacocoTaskExtension.Output`
  The types of output that the agent can use for execution data.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JacocoTaskExtension(org.gradle.internal.jacoco.JacocoAgentJar agent, JavaForkOptions task)`
  Creates a Jacoco task extension.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract Property<String>`
  `getAddress()`
  IP address or hostname to use with `JacocoTaskExtension.Output.TCP_SERVER` or `JacocoTaskExtension.Output.TCP_CLIENT`.
  `FileCollection`
  `getAgentClasspath()`
  The Jacoco agent classpath.
  `Provider<String>`
  `getAsJvmArg()`
  Gets all properties in the format expected of the agent JVM argument.
  `abstract DirectoryProperty`
  `getClassDumpDir()`
  Path to dump all class files the agent sees are dumped to.
  `abstract RegularFileProperty`
  `getDestinationFile()`
  The path for execution data to be written to.
  `protected @Nullable File`
  `getDestinationFileOutput()`
  Deprecated.
  `abstract Property<Boolean>`
  `getDumpOnExit()`
  Whether or not to dump the coverage data at VM shutdown.
  `abstract Property<Boolean>`
  `getEnabled()`
  Whether or not the task should generate execution data.
  `abstract ListProperty<String>`
  `getExcludeClassLoaders()`
  List of classloader names that should be excluded from analysis.
  `abstract ListProperty<String>`
  `getExcludes()`
  List of class names that should be excluded from analysis.
  `abstract Property<Boolean>`
  `getIncludeNoLocationClasses()`
  Whether or not classes without source location should be instrumented.
  `abstract ListProperty<String>`
  `getIncludes()`
  List of class names that should be included in analysis.
  `Property<Boolean>`
  `getIsDumpOnExit()`
  `Property<Boolean>`
  `getIsEnabled()`
  `Property<Boolean>`
  `getIsIncludeNoLocationClasses()`
  `Property<Boolean>`
  `getIsJmx()`
  `abstract Property<Boolean>`
  `getJmx()`
  Whether or not to expose functionality via JMX under `org.jacoco:type=Runtime`.
  `abstract Property<JacocoTaskExtension.Output>`
  `getOutput()`
  The type of output to generate.
  `abstract Property<Integer>`
  `getPort()`
  Port to bind to for `JacocoTaskExtension.Output.TCP_SERVER` or `JacocoTaskExtension.Output.TCP_CLIENT`.
  `abstract Property<String>`
  `getSessionId()`
  An identifier for the session written to the execution data.

  ### Methods inherited from class java.lang.Object

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

- ## 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 analysis
      `task` - the task we extend

- ## Method Details

  - ### getEnabled

    @Input public abstract Property<Boolean> getEnabled()
    Whether or not the task should generate execution data. Defaults to `true`.

  - ### getIsEnabled

    @Internal public Property<Boolean> getIsEnabled()

  - ### getDestinationFile

    @Internal public abstract RegularFileProperty getDestinationFile()
    The path for execution data to be written to.
    Returns:
      destination file for execution data output
    Since:
      4.0

  - ### getDestinationFileOutput

    @Deprecated @Incubating @Optional @OutputFile protected @Nullable File getDestinationFileOutput()
    Deprecated.
    This method exists because `getDestinationFile()` cannot be annotated with `@OutputFile` directly, 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.6.0

  - ### getIncludes

    @Optional @Input public abstract ListProperty<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.

  - ### getExcludes

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

  - ### getExcludeClassLoaders

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

  - ### getIncludeNoLocationClasses

    @Input public abstract Property<Boolean> getIncludeNoLocationClasses()
    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)

  - ### getIsIncludeNoLocationClasses

    @Internal public Property<Boolean> getIsIncludeNoLocationClasses()

  - ### getSessionId

    @Optional @Input public abstract Property<String> getSessionId()
    An identifier for the session written to the execution data. Defaults to an auto-generated identifier.

  - ### getDumpOnExit

    @Input public abstract Property<Boolean> getDumpOnExit()
    Whether or not to dump the coverage data at VM shutdown. Defaults to `true`.

  - ### getIsDumpOnExit

    @Internal public Property<Boolean> getIsDumpOnExit()

  - ### getOutput

    @Input public abstract Property<JacocoTaskExtension.Output> getOutput()
    The type of output to generate. Defaults to `JacocoTaskExtension.Output.FILE`.

  - ### getAddress

    @Optional @Input public abstract Property<String> getAddress()
    IP address or hostname to use with `JacocoTaskExtension.Output.TCP_SERVER` or `JacocoTaskExtension.Output.TCP_CLIENT`. Defaults to localhost.

  - ### getPort

    @Input public abstract Property<Integer> getPort()
    Port to bind to for `JacocoTaskExtension.Output.TCP_SERVER` or `JacocoTaskExtension.Output.TCP_CLIENT`. Defaults to 6300.

  - ### getClassDumpDir

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

  - ### getJmx

    @Input public abstract Property<Boolean> getJmx()
    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)

  - ### getIsJmx

    @Internal public Property<Boolean> getIsJmx()

  - ### getAgentClasspath

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

  - ### getAsJvmArg

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