About GroboUtils


For Developers

GroboCodeCoverage version 1.1.0

CoveragePostCompiler: GroboCoverage Ant Tasks

Author:Matt Albrecht

All Tasks



Deprecated - use grobo-instrument instead.

Recompiles the provided class files to a separate directory, and stores the compilation generated data (for use in report generation) to another directory.

Nested Elements


the FileSet to use for defining all the class files to recompile. Note that no matter what is specified in the file sets, only files ending in ".class" (case-insensitive) will be recompiled. There may be multiple of these file sets specified.


Defines a single analysis module to use in the analysis of each class file that is recompiled. An analysis module creates coverage details for the class specific to its measure, such as line-count or branch count. Multiple of these modules may be specified. Each analysis module will have its own report generated.


namethe name of the analysis module to load. The only current acceptable values are:
  • linecount: counts the source code line coverage. This requires the line information to be stored in the class file.
  • bytecode: counts the coverage of the class file's bytecode. This is the most detailed look at exactly what amount of code is and is not being covered, but can be hard to read.
  • branch: counts the coverage of each branch by looking at the bytecode branching instructions.
  • call-pair: counts the coverage of each method invocation.
  • function: counts the "function" or "method" entry coverage; when the execution enters a method, that method is marked as covered.
One of name (alternatively, type) or classname must be specified
typean alternative to the name attribute. One of name (alternatively, type) or classname must be specified
classnameLoads a non-standard analysis module, using this parameter as a the fully-qualified class name of the analysis module class. If this is specified, then it will use the classpathref parameter, embedded classpath element, or loaderref parameter to reference the classpath from which to load the module, if any are provided. If none are provided, then the classloader for the task will be used instead. One of name (alternatively, type) or classname must be specified
classpathrefReference to a classpath to use when looking up classname. No
loaderRefthe name of the loader that is used to load the class, constructed from the specified classpath. Use this to allow multiple tasks/types to be loaded with the same loader, so they can call each other. No

Nested Elements


Analysismodule's classpath attribute is a PATH like structure and can also be set via a nested classpath element.


Sets up how the logs are generated by the covered classes. This allows for configuration of the file (which tells the coverage-enabled classes everything they need during operation to run correctly), and generates that properties file for you.


factorythe factory class to handle the logging. If no package is specified, then this property will prepend "net.sourceforge.groboutils.codecoverage.v2.logger." to the given factory name. Currently, there are two types of loggers:
  1. DirectoryChannelLoggerFactory:(default) This is the safest logger, but the slowest. On each logging request, it opens the log file, writes the log element, then closes the log file, all in a VM-wide synchronized block. Using this logger, you will likely see a large amount of disk access. The logDir parameter (below) defines the directory to place all the channel log data (default directory is "./.cover-logs").
  2. CacheDirChannelLoggerFactory: This is a faster logger. It keeps a sized cache of open log files in memory, each log file being a buffered file. This has a danger of possibly not closing or flushing its open log files on VM shutdown. If the VM is JDK 1.3 compatible, the logger will add a shutdown hook to attempt to close its opened files. Using this logger, you should see large disk access when the VM ends. It uses the logDir parameter (below) that the DirectoryChannelLoggerFactory uses, and also uses the cachesize parameter, which defines the maximum number of opened files stored in the cache per channel (default size is 25, but you should match this to the limitations of the operating system).

    There's a pending issue with this logger (bug 902884).

  3. MinDirChannelLoggerFactory: This operates identically to DirectoryChannelLoggerFactory, but caches the encountered covered items, and only writes new elements to the log files. This is JDK 1.2 dependent, and may eat up lots of memory. However, for those that are encountering issues due to enormous log files, moving to this logger should fix the problem. Also, this should reduce file I/O.
logDirthe directory that all the coverage logging data will be put. Must match the report task's logDir parameter. No
cachesizethe number of concurrent files to keep open. Only used by the CacheDirChannelLoggerFactory. No


datadirthe name of the directory to send the analysis module generated data to. This same directory should be specified in the coveragereport task's datadir attribute as well. Yes
outclassdirThe name of the directory in which the recompiled class files are saved. This directory should never be confused with the original classes: these classes are slower and "fatter" than the originals. Yes


    <analysismodule name="linecount" />
    <fileset dir="${dirs.classes}" />
    <fileset dir="${dirs.classes2}">
        <excludes name="dont/cover/these/*.class" />
    <logsettings logdir="coverage/logs" />
Recompiles all the classes located in ${dirs.classes} using the linecount analysis module, and recompiles all the classes from ${dirs.classes2} except those in the dont.cover.these package. All the recompiled classes are stored in coverage/classes, and the analysis module generated data is stored under the coverage/data directory. The default logger factory (DirectoryChannelLoggerFactory) will be used during runs, outputting log data to coverage/logs.

All Tasks

SourceForge Logo
This space graciously provided by the SourceForge project
Copyright © 2002-2004 GroboUtils Project.
All rights reserved.