Skip to content

Commit 14550cf

Browse files
committed
Merge branch 'release/1.7' into 'master' (#93)
2 parents 675b84e + 49c203e commit 14550cf

File tree

16 files changed

+292
-108
lines changed

16 files changed

+292
-108
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ build/
1616
*/out/*/classes/*
1717
plugin/src/test/test-fixtures/multi-module/gradle.properties
1818
plugin/src/test/test-fixtures/multi-module/build.gradle
19+
plugin/src/test/test-fixtures/multi-module/app/build.gradle

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ following methods:
2929
```groovy
3030
// Below buildscript {}
3131
plugins {
32-
id "nl.neotech.plugin.rootcoverage" version "1.7.0"
32+
id "nl.neotech.plugin.rootcoverage" version "1.7.1"
3333
}
3434
```
3535
</details>
@@ -42,7 +42,7 @@ following methods:
4242
4343
buildscript {
4444
dependencies {
45-
classpath 'nl.neotech.plugin:android-root-coverage-plugin:1.7.0'
45+
classpath 'nl.neotech.plugin:android-root-coverage-plugin:1.7.1'
4646
}
4747
}
4848
```
@@ -141,7 +141,7 @@ rootCoverage {
141141
|--------------------|--------------------------------------------------------------------------------------------------------------|-------------------|
142142
| **1.8.0-SNAPSHOT** | 8.3.0-alpha05 | 8.4+ *(note 1)* |
143143
| **Note 2** | 8.0-8.3.0-alpha04 | n.a. |
144-
| **1.7.0** | 7.4 | 7.5+ |
144+
| **1.7.1** | 7.4 | 7.5+ |
145145
| **1.6.0** | 7.3 | 7.4+ |
146146
| **1.5.3** | 7.2 | 7.3+ |
147147
| **Note 3** | 7.0-7.2.0-alpha05 | n.a. |

gradle/libs.versions.toml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ androidGradlePlugin = { module = "com.android.tools.build:gradle", vers
1111
androidGradlePluginApi = { module = "com.android.tools.build:gradle-api", version.ref = "androidGradlePlugin" }
1212

1313
# Test dependencies
14-
junit = { module = "junit:junit", version = "4.13.2" }
15-
truth = { module = "com.google.truth:truth", version = "1.1.3" }
16-
supportTestRunner = { module = "androidx.test:runner", version = "1.5.2" }
17-
espressoCore = { module = "androidx.test.espresso:espresso-core", version = "3.5.1" }
18-
androidJUnit = { module = "androidx.test.ext:junit", version = "1.1.5" }
19-
commonsCsv = { module = "org.apache.commons:commons-csv", version = "1.10.0" }
20-
kotlinTest = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
21-
robolectric = { module = "org.robolectric:robolectric", version = "4.10.2" }
22-
mockk = { module = "io.mockk:mockk", version = "1.13.5" }
14+
junit = { module = "junit:junit", version = "4.13.2" }
15+
truth = { module = "com.google.truth:truth", version = "1.1.3" }
16+
supportTestRunner = { module = "androidx.test:runner", version = "1.5.2" }
17+
espressoCore = { module = "androidx.test.espresso:espresso-core", version = "3.5.1" }
18+
androidJUnit = { module = "androidx.test.ext:junit", version = "1.1.5" }
19+
commonsCsv = { module = "org.apache.commons:commons-csv", version = "1.10.0" }
20+
kotlinTest = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
21+
robolectric = { module = "org.robolectric:robolectric", version = "4.10.2" }
22+
mockk = { module = "io.mockk:mockk", version = "1.13.5" }
23+
jacksonYaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml", version = "2.15.3"}
24+
jacksonKotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version = "2.15.3"}
2325

2426
[bundles]
2527
androidInstrumentedTest = ["supportTestRunner", "espressoCore", "androidJUnit"]

plugin/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ dependencies {
8787
testImplementation libs.bundles.jvmTest
8888
testImplementation gradleTestKit()
8989
testImplementation libs.mockk
90+
testImplementation libs.jacksonYaml
91+
testImplementation libs.jacksonKotlin
9092
}
9193

9294
// Setup Jacoco for Gradle TestKit

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ internal fun RootCoveragePluginExtension.getFileFilterPatterns(): List<String> =
3535
internal fun RootCoveragePluginExtension.getBuildVariantFor(project: Project): String =
3636
buildVariantOverrides[project.path] ?: buildVariant
3737

38-
internal fun Project.getExecutionDataFileTree(includeUnitTestResults: Boolean, includeAndroidTestResults: Boolean): FileTree? {
38+
internal fun Project.getExecutionDataFileTree(includeUnitTestResults: Boolean, includeConnectedDevicesResults: Boolean, includeGradleManagedDevicesResults: Boolean): FileTree? {
3939
val buildFolderPatterns = mutableListOf<String>()
4040
if (includeUnitTestResults) {
4141
// TODO instead of hardcoding this, obtain the location from the test tasks, something like this?
@@ -54,7 +54,7 @@ internal fun Project.getExecutionDataFileTree(includeUnitTestResults: Boolean, i
5454
// Android Build Tools Plugin 7.0+
5555
buildFolderPatterns.add("outputs/unit_test_code_coverage/*/*.exec")
5656
}
57-
if (includeAndroidTestResults) {
57+
if (includeConnectedDevicesResults) {
5858

5959
// These are legacy paths for older now unsupported AGP version, they are just here for
6060
// reference and are not added to prevent existing files from polluting results
@@ -67,7 +67,8 @@ internal fun Project.getExecutionDataFileTree(includeUnitTestResults: Boolean, i
6767

6868
// Android Build Tools Plugin 7.1+
6969
buildFolderPatterns.add("outputs/code_coverage/*/connected/*/coverage.ec")
70-
70+
}
71+
if(includeGradleManagedDevicesResults) {
7172
// Gradle Managed Devices 7.4
7273
// buildFolderPatterns.add("outputs/managed_device_code_coverage/*/coverage.ec")
7374

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ class RootCoveragePlugin : Plugin<Project> {
145145
if (rootProjectExtension.shouldExecuteUnitTests() && (buildType.enableUnitTestCoverage || buildType.isTestCoverageEnabled)) {
146146
dependsOn("$path:test${name}UnitTest")
147147
}
148+
149+
var runsOnGradleManagedDevices = false
150+
148151
if (rootProjectExtension.shouldExecuteAndroidTests() && (buildType.enableAndroidTestCoverage || buildType.isTestCoverageEnabled)) {
149152

150153
// Attempt to run on instrumented tests, giving priority to the following devices in this order:
@@ -153,16 +156,26 @@ class RootCoveragePlugin : Plugin<Project> {
153156
// - All through ADB connected devices.
154157
val gradleManagedDevices = subProject.extensions.getByType(BaseExtension::class.java).testOptions.managedDevices.devices
155158
if (rootProjectExtension.runOnGradleManagedDevices && !rootProjectExtension.gradleManagedDeviceName.isNullOrEmpty()) {
159+
runsOnGradleManagedDevices = true
156160
dependsOn("$path:${rootProjectExtension.gradleManagedDeviceName}${name}AndroidTest")
157161
} else if (rootProjectExtension.runOnGradleManagedDevices && gradleManagedDevices.isNotEmpty()) {
162+
runsOnGradleManagedDevices = true
158163
dependsOn("$path:allDevices${name}AndroidTest")
159164
} else {
160165
dependsOn("$path:connected${name}AndroidTest")
161166
}
162167
} else {
163168
// If this plugin should not run instrumented tests on it's own, at least make sure it runs after those tasks (if they are
164-
// selected to run as well).
165-
mustRunAfter("$path:allDevices${name}AndroidTest")
169+
// selected to run as well and exists).
170+
//
171+
// In theory we don't need to do this if `rootProjectExtension.includeAndroidTestResults` is false, so we could check that, but
172+
// it also does not hurt.
173+
174+
val executeAndroidTestsOnGradleManagedDevicesTask = project.tasks.findByPath("$path:allDevices${name}AndroidTest")
175+
if(executeAndroidTestsOnGradleManagedDevicesTask != null) {
176+
// This task only exists if a Gradle Managed Device is configured, which may not be the case.
177+
mustRunAfter("$path:allDevices${name}AndroidTest")
178+
}
166179
mustRunAfter("$path:connected${name}AndroidTest")
167180
}
168181

@@ -181,7 +194,8 @@ class RootCoveragePlugin : Plugin<Project> {
181194
executionData.from(
182195
subProject.getExecutionDataFileTree(
183196
includeUnitTestResults = rootProjectExtension.includeUnitTestResults && (buildType.enableUnitTestCoverage || buildType.isTestCoverageEnabled),
184-
includeAndroidTestResults = rootProjectExtension.includeAndroidTestResults && (buildType.enableAndroidTestCoverage || buildType.isTestCoverageEnabled)
197+
includeConnectedDevicesResults = rootProjectExtension.includeAndroidTestResults && (buildType.enableAndroidTestCoverage || buildType.isTestCoverageEnabled) && !runsOnGradleManagedDevices,
198+
includeGradleManagedDevicesResults = rootProjectExtension.includeAndroidTestResults && (buildType.enableAndroidTestCoverage || buildType.isTestCoverageEnabled) && runsOnGradleManagedDevices
185199
)
186200
)
187201
}

0 commit comments

Comments
 (0)