Skip to content

Commit e2d0d99

Browse files
author
Marcel Schnelle
authored
Update access to resCollection (#88)
1 parent 983fccf commit e2d0d99

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

android-junit5/src/main/groovy/de/mannodermaus/gradle/plugins/junit5/GroovyInterop.groovy

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@ class GroovyInterop {
9797
return collection == null ? null : collection.files
9898
}
9999

100+
/**
101+
* Obtains the Res Collection of the given AndroidUnitTest.
102+
*
103+
* @because 'resCollection' type changed from FileCollection to BuildArtifact in Android Gradle Plugin 3.2.0-alpha11
104+
* @param test The Android JUnit 4 test to access
105+
* @return Its assets collection
106+
*/
107+
@Nullable
108+
static Set<File> androidUnitTest_resCollection(AndroidUnitTest test) {
109+
def collection = test.resCollection
110+
return collection == null ? null : collection.files
111+
}
112+
100113
/**
101114
* Obtains the Merged Manifest of the given AndroidUnitTest.
102115
*

android-junit5/src/main/kotlin/de/mannodermaus/gradle/plugins/junit5/Interop.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ val BaseVariant.variantData: BaseVariantData
2020
val VariantScope.safeJavaOutputDirs: Set<File>
2121
get() = GroovyInterop.variantScope_javaOutputDirs(this)
2222

23+
val AndroidUnitTest.safeResCollection: Set<File>?
24+
get() = GroovyInterop.androidUnitTest_resCollection(this)
25+
2326
val AndroidUnitTest.safeAssetsCollection: Set<File>?
2427
get() = GroovyInterop.androidUnitTest_assetsCollection(this)
2528

android-junit5/src/main/kotlin/de/mannodermaus/gradle/plugins/junit5/tasks/UnitTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import de.mannodermaus.gradle.plugins.junit5.providers.DirectoryProvider
1313
import de.mannodermaus.gradle.plugins.junit5.providers.classDirectories
1414
import de.mannodermaus.gradle.plugins.junit5.safeAssetsCollection
1515
import de.mannodermaus.gradle.plugins.junit5.safeMergedManifest
16+
import de.mannodermaus.gradle.plugins.junit5.safeResCollection
1617
import de.mannodermaus.gradle.plugins.junit5.variantData
1718
import org.gradle.api.DefaultTask
1819
import org.gradle.api.Project
@@ -196,7 +197,7 @@ open class AndroidJUnit5UnitTest : JavaExec(), JUnit5UnitTest {
196197
junit5: AndroidJUnitPlatformExtension) {
197198
// Connect to the default unit test task
198199
val variantUnitTestTask = this.getDefaultJUnit4Task()
199-
task.resCollection = variantUnitTestTask.resCollection?.files
200+
task.resCollection = variantUnitTestTask.safeResCollection
200201
task.assetsCollection = variantUnitTestTask.safeAssetsCollection
201202
task.sdkPlatformDirPath = variantUnitTestTask.sdkPlatformDirPath
202203
task.mergedManifest = variantUnitTestTask.safeMergedManifest

0 commit comments

Comments
 (0)