File tree Expand file tree Collapse file tree 4 files changed +29
-32
lines changed
Expand file tree Collapse file tree 4 files changed +29
-32
lines changed Original file line number Diff line number Diff line change 1+ import org.gradle.api.Project
2+
3+ // Use local project dependencies on android-test instrumentation libraries
4+ // for the modules inside this repository, instead of relying on their Maven coordinates.
5+ // This is not needed for normal consumers, but we want it to test our own code.
6+ private val instrumentationLibraryRegex =
7+ Regex (" de\\ .mannodermaus\\ .junit5:android-test-([a-z0-9]+)(-.+)?:" )
8+
9+ fun Project.replaceAndroidTestLibsWithLocalProjectDependencies () {
10+ val self = this
11+
12+ configurations.all {
13+ if (" DebugAndroidTestRuntimeClasspath" in name) {
14+ resolutionStrategy.dependencySubstitution.all {
15+ instrumentationLibraryRegex.find(requested.toString())?.let { result ->
16+ val replacement = project(" :${result.groupValues[1 ]} " )
17+ println (
18+ " In $self , replace androidTest dependency '$requested ' with $replacement "
19+ )
20+ useTarget(replacement)
21+ }
22+ }
23+ }
24+ }
25+ }
Original file line number Diff line number Diff line change @@ -18,14 +18,7 @@ android {
1818 buildFeatures { compose = true }
1919}
2020
21- junitPlatform {
22- // Using local dependency instead of Maven coordinates
23- instrumentationTests.enabled = false
24-
25- // Fail test execution when running on unsupported device
26- // (TODO: Change this to the proper instrumentationTests API once released as stable)
27- configurationParameter(" de.mannodermaus.junit.unsupported.behavior" , " fail" )
28- }
21+ replaceAndroidTestLibsWithLocalProjectDependencies()
2922
3023dependencies {
3124 implementation(project(" :core" ))
Original file line number Diff line number Diff line change @@ -18,25 +18,9 @@ junitPlatform {
1818 // See TaggedTests.kt for usage of this tag
1919 excludeTags(" nope" )
2020 }
21-
22- // Fail test execution when running on unsupported device
23- // (TODO: Change this to the proper instrumentationTests API once released as stable)
24- configurationParameter(" de.mannodermaus.junit.unsupported.behavior" , " fail" )
2521}
2622
27- // Use local project dependencies on android-test instrumentation libraries
28- // instead of relying on their Maven coordinates for this module
29- val instrumentationLibraryRegex = Regex (" de\\ .mannodermaus\\ .junit5:android-test-(.+):" )
30-
31- configurations.all {
32- if (" DebugAndroidTestRuntimeClasspath" in name) {
33- resolutionStrategy.dependencySubstitution.all {
34- instrumentationLibraryRegex.find(requested.toString())?.let { result ->
35- useTarget(project(" :${result.groupValues[1 ]} " ))
36- }
37- }
38- }
39- }
23+ replaceAndroidTestLibsWithLocalProjectDependencies()
4024
4125dependencies {
4226 implementation(libs.kotlin.stdlib)
Original file line number Diff line number Diff line change @@ -37,15 +37,10 @@ android {
3737junitPlatform {
3838 // Configure JUnit 5 tests here
3939 filters(" debug" ) { excludeTags(" slow" ) }
40-
41- // Using local dependency instead of Maven coordinates
42- instrumentationTests.enabled = false
43-
44- // Fail test execution when running on unsupported device
45- // (TODO: Change this to the proper instrumentationTests API once released as stable)
46- configurationParameter(" de.mannodermaus.junit.unsupported.behavior" , " fail" )
4740}
4841
42+ replaceAndroidTestLibsWithLocalProjectDependencies()
43+
4944dependencies {
5045 implementation(libs.kotlin.stdlib)
5146
You can’t perform that action at this time.
0 commit comments