class CoberturaPlugin extends java.lang.Object
Provides Cobertura coverage for Test tasks.
This plugin will create 4 tasks.
The first is the "cobertura" task that users may call to generate coverage
reports. This task will run the all tasks named "test" from the directory
where gradle was invoked as well as "test" tasks in any sub projects. In
addition, it will run all tasks of type Test in the project applying
the plugin. It is designed to do the same thing as "gradle test", but with
all testing tasks running in the applying project and coverage reports
generated at the end of the build. This task doesn't actually do any work,
it is used by the plugin to determine user intent. This task will do the
right thing for most users.
The second task is called "coberturaReport". Users may call this task to tell Gradle that coverage reports should be generated after tests are run, but without causing any tests to actually run. This allows users to have more fine-grained control over the tasks that get run by requiring them to specify the desired tasks on the command line.
The third task is the "instrument" task, that will instrument the source code. Users won't call it directly, but the plugin will make all test tasks depend on it so that instrumentation only happens once, and only if the task graph has the "cobertura" or "coberturaReport" task in the execution graph.
The fourth task is the "copyCoberturaDatafile" task, which copies the input datafile, generated by the instrument task, to the output datafile, which is is modified by tests and used to generate the coverage report. This task must run whenever we want a coverage report to make sure the data in it is for the current run only.
The fifth task is the "generateCoberturaReport" task, which does the actual work of generating the coverage reports if the "cobertura" or "coberturaReport" tasks are in the execution graph.
This plugin also defines a "cobertura" extension with properties that are used to configure the operation of the plugin and its tasks. The plugin runs cobertura coverage reports for sourceSets.main. A project might have have multiple artifacts that use different parts of the code, and there may be different test tasks that test different parts of the source, but there is almost always only one main source set. Most of the magic of this plugin happens not at apply time, but when tasks are added and when the task graph is ready. If the graph contains the "cobertura" or "coberturaReport" task, it will make sure the instrument and generateCoberturaReport" tasks are configured to do actual work, and that task dependencies are what they need to be for the users to get what they want.
| Type | Name and description |
|---|---|
static java.lang.String |
COBERTURA_CHECK_TASK_NAME |
static java.lang.String |
COBERTURA_REPORT_TASK_NAME |
static java.lang.String |
COBERTURA_TASK_NAME |
| Type | Name and description |
|---|---|
void |
apply(org.gradle.api.Project project) |
static boolean |
isAndroidProject(org.gradle.api.Project project) |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |