Class JacocoTaskExtension


  • @Incubating
    public class JacocoTaskExtension
    extends Object
    Extension for tasks that should run with a Jacoco agent to generate coverage execution data.
    • Constructor Detail

      • JacocoTaskExtension

        public JacocoTaskExtension​(Project project,
                                   org.gradle.internal.jacoco.JacocoAgentJar agent,
                                   JavaForkOptions task)
        Creates a Jacoco task extension.
        Parameters:
        project - the project
        agent - the agent JAR to use for analysis
        task - the task we extend
    • Method Detail

      • isEnabled

        public boolean isEnabled()
        Whether or not the task should generate execution data. Defaults to true.
      • setEnabled

        public void setEnabled​(boolean enabled)
      • getDestinationFile

        public File getDestinationFile()
        The path for the execution data to be written to.
      • 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​(File destinationFile)
      • isAppend

        public boolean isAppend()
        Whether or not data should be appended if the destinationFile already exists. Defaults to true.
      • setAppend

        public void setAppend​(boolean append)
      • getIncludes

        public 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.
      • setIncludes

        public void setIncludes​(List<String> includes)
      • getExcludes

        public List<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​(List<String> excludes)
      • getExcludeClassLoaders

        public List<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​(List<String> excludeClassLoaders)
      • isIncludeNoLocationClasses

        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)
      • setIncludeNoLocationClasses

        public void setIncludeNoLocationClasses​(boolean includeNoLocationClasses)
      • getSessionId

        public String getSessionId()
        An identifier for the session written to the execution data. Defaults to an auto-generated identifier.
      • setSessionId

        public void setSessionId​(String sessionId)
      • isDumpOnExit

        public boolean isDumpOnExit()
        Whether or not to dump the coverage data at VM shutdown. Defaults to true.
      • setDumpOnExit

        public void setDumpOnExit​(boolean dumpOnExit)
      • setAddress

        public void setAddress​(String address)
      • setPort

        public void setPort​(int port)
      • getClassDumpDir

        public 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​(File classDumpDir)
        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 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)
      • setJmx

        public void setJmx​(boolean jmx)
      • getAsJvmArg

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