Skip to content

Commit 81ba4a2

Browse files
committed
Added property to skip the test execution (useful when testing filters etc.)
1 parent 87f126f commit 81ba4a2

File tree

6 files changed

+22
-8
lines changed

6 files changed

+22
-8
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Generating code coverage reports for Android Projects that make use of the Gradl
99
# Setup
1010
Apply the Android-Root-Coverage-Plugin plugin to your top-level (root project) gradle file following these 2 steps:
1111

12-
```
12+
```groovy
1313
// Step 2: Apply the plugin to the top-level gradle file
1414
apply plugin: 'org.neotech.plugin.rootcoverage'
1515
@@ -25,7 +25,7 @@ buildscript {
2525
Currently only modules with the plugin type `com.android.application` or `com.android.library` are taken into account when generating the root code coverage report, besides this any module that does not have `testCoverageEnabled true` for the default build variant (`debug`) will be skipped::
2626

2727
You can add a module by enabling `testCoverageEnabled`:
28-
```
28+
```groovy
2929
android {
3030
buildTypes {
3131
debug {
@@ -43,14 +43,16 @@ The Android-Root-Coverage-Plugin generates a special Gradle task `:rootCodeCover
4343
# Configuration
4444
By default the plugin generates code coverage reports using the build variant `debug` for every module. However in some cases different build variants per module might be required, especially if there is no `debug` build variant available. In those cases you can configure custom build variants for specific modules:
4545

46-
```
46+
```groovy
4747
rootCoverage {
4848
// The default build variant for every module
4949
buildVariant "debug"
5050
// Overrides the default build variant for specific modules.
5151
buildVariantOverrides ":moduleA" : "debugFlavourA", ":moduleB": "debugFlavourA"
5252
// Class exclude patterns
53-
excludes ["**/library.a/**"]
53+
excludes = ["**/some.package/**"]
54+
// If true the task it self does not execute any tests (debug option)
55+
skipTestExecution false
5456
}
5557
```
5658

build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ buildscript {
3333
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
3434
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
3535

36-
classpath 'org.neotech.plugin:android-root-coverage-plugin:0.0.1-dev'
36+
classpath 'org.neotech.plugin:android-root-coverage-plugin:0.0.2-dev'
3737
// NOTE: Do not place your application dependencies here; they belong
3838
// in the individual module build.gradle files
3939
}
@@ -58,5 +58,6 @@ jacoco {
5858
rootCoverage {
5959
buildVariant "debug"
6060
buildVariantOverrides ":library_a" : "debug", ":library_b": "debug"
61-
//excludes ["**/library.a/**"]
61+
//excludes = ["**/LibraryAJava.class"]
62+
//skipTestExecution true
6263
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ org.gradle.jvmargs=-Xmx1536m
1919
#PACKAGING=jar
2020

2121
GROUP=org.neotech.plugin
22-
VERSION=0.0.1-dev
22+
VERSION=0.0.2-dev
2323
DESCRIPTION=A Gradle plugin for easy generation of combined code coverage reports for Android projects with multiple modules.
2424

2525
PROJECT_WEBSITE=https://github.com/NeoTech-Software/android-root-coverage-plugin

plugin/src/main/kotlin/org/neotech/plugin/rootcoverage/RootCoverageModuleTask.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package org.neotech.plugin.rootcoverage
22

33
import org.gradle.api.DefaultTask
44
import org.gradle.api.file.FileCollection
5+
import org.gradle.api.tasks.Input
6+
import org.gradle.api.tasks.InputFiles
57

68
/**
79
* This Task currently does not really do anything, except for having dependencies on the submodules
@@ -10,8 +12,13 @@ import org.gradle.api.file.FileCollection
1012
*/
1113
open class RootCoverageModuleTask: DefaultTask() {
1214

15+
@InputFiles
1316
var executionData: FileCollection = project.files()
17+
18+
@InputFiles
1419
var sourceDirectories: FileCollection = project.files()
20+
21+
@InputFiles
1522
var classDirectories: FileCollection = project.files()
1623

1724
}

plugin/src/main/kotlin/org/neotech/plugin/rootcoverage/RootCoveragePlugin.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ class RootCoveragePlugin: Plugin<Project> {
168168
val task = project.tasks.create("codeCoverageReport$name", RootCoverageModuleTask::class.java)
169169
task.group = null // null makes sure the group does not show in the gradle-view in Android Studio/Intellij
170170
task.description = "Generate unified Jacoco code codecoverage report"
171-
task.dependsOn("test${name}UnitTest", "connected${name}AndroidTest")
171+
172+
if(!rootProjectExtension.skipTestExecution) {
173+
task.dependsOn("test${name}UnitTest", "connected${name}AndroidTest")
174+
}
172175

173176
// Collect the class files based on the Java Compiler output
174177
val javaClassTrees = variant.javaCompiler.outputs.files.map { file ->

plugin/src/main/kotlin/org/neotech/plugin/rootcoverage/RootCoveragePluginExtension.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ open class RootCoveragePluginExtension {
55
var buildVariant: String = "debug"
66
var buildVariantOverrides: Map<String, String> = mutableMapOf()
77
var excludes: List<String> = mutableListOf()
8+
var skipTestExecution: Boolean = false
89
}

0 commit comments

Comments
 (0)