This tool copies and instruments a set of Java source files specified on the command line. The output of the instrumentation process is instrumented java source; you will then need to compile the instrumented source using a standard Java compiler.
java com.atlassian.clover.CloverInstr [OPTIONS] PARAMS [FILES...]
Note: in Clover 3.1.x and older a class was named com.cenqua.clover.CloverInstr.
-i, --initstring <file> | Clover initstring. This is the full path to the dbfile that will be used to construct/update to store coverage data. |
-s, --srcdir <dir> | Directory containing source files to be instrumented. If omitted individual source files should be specified on the command line. |
-d, --destdir <dir> | Directory where Clover should place the instrumented sources. Note that files will be overwritten in the destination directory. |
-dc, --distributedCoverage <string> | Configuration for recording distributed pre-test coverage. Valid keys and default values are: ON | OFF | |
--dontFullyQualifyJavaLang | If set, then java.lang will not be used in instrumented source. |
-e, --encoding <encoding> | Specify the file encoding for source files. If not specified, the platform default encoding is used. |
-f, --flushinterval <int> | Tell Clover how often to flush coverage data when using either "interval" or "threaded" flushpolicy. Value in milliseconds. |
--instrumentation <policy> | Set the instrumentation strategy. Valid values are "field" and "class". Default is "class". |
--instrlevel <string> | Set the instrumentation level. Valid values are "statement" and "method". Default is "statement". |
--instrlambda <string> | Whether to instrument lambda functions. Valid values are:
Since Clover 3.2.2. |
-p, --flushpolicy <policy> | Tell Clover which flushpolicy to use when flushing coverage data to disk. Valid values are "directed", "interval" and "threaded". With "interval" or "threaded", you must also specify a flushinterval using -f. The default value is "directed". |
-mc --methodContext <name>=<regexp> | Defines a single custom method context. May be supplied more than once. (The \ may be needed to prevent shell expansion) |
-sc --statementContext <name>=<regexp> | Defines a single custom statement context. May be supplied more than once. (The \ may be needed to prevent shell expansion) |
-r, --relative | If specified, the initstring is treated as a relative path, rather than being converted to an absolute path. This is useful for distributed testing environments. |
--recordTestResults <true|false> | If set to " |
--source <level> | Set the language level for Clover to use when parsing files. |
--sourceRoot <string> | Source root path prefix that will be ignored when evaluating the test inclusion patterns. This parameter is optional; it specifies what is trimmed from the beginning of the file path before the tests Include/Exclude Pattern is evaluated (see parameters below). For example, if you specify |
-v, --verbose | Enable verbose logging. |
CloverInstr provides a simple API that accepts an array of strings representing the command line arguments and returns an integer result code. The following fragment illustrates use of the API:
import com.atlassian.clover.CloverInstr; ... String [] cliArgs = { "-jdk14", "-i", "clover.db", "-d", "build/instr", "Money.java" } ; int result = CloverInstr.mainImpl(cliArgs); if (result != 0) { // problem during instrumentation }
java com.atlassian.clover.CloverInstr -i clover.db -s src -d build/instr
Find all java source files in the directory "src", copy and instrument them into the directory "build/instr", which will be constructed if it does not exist. Coverage database "clover.db" is initialised.
java com.atlassian.clover.CloverInstr --source 1.4 -i clover.db -d ../../build/instr \ Money.java IMoney.java
Copy and instrument the source files "Money.java" and "IMoney.java" into the directory "../../build/instr"
. Use the JDK1.4 grammar (i.e. support the 'assert' keyword).