@@ -8,6 +8,9 @@ import org.gradle.api.logging.Logger
88import org.gradle.api.logging.Logging
99import org.gradle.api.tasks.testing.Test
1010
11+ import java.nio.file.Files
12+ import java.nio.file.Paths
13+
1114class AndroidGradleUtils {
1215
1316 private static final Logger LOGGER = Logging . getLogger(AndroidGradleUtils )
@@ -29,7 +32,10 @@ class AndroidGradleUtils {
2932 }
3033
3134 private static getVariant (Project project , Test task ) {
32- def androidPlugin = project. plugins. findPlugin(' android' ) ?: project. plugins. findPlugin(' android-library' )
35+ def androidPlugin = project. plugins. findPlugin(' android' )
36+ ?: project. plugins. findPlugin(' android-library' )
37+ ?: project. plugins. findPlugin(' com.android.application' )
38+ ?: project. plugins. findPlugin(' com.android.library' )
3339
3440 def variants
3541 if (androidPlugin. class. simpleName == ' LibraryPlugin' ) {
@@ -39,7 +45,7 @@ class AndroidGradleUtils {
3945 }
4046
4147 for (def v : variants) {
42- if (task. path. endsWith(" test${ v.name.capitalize()} UnitTest" )) {
48+ if (task. path. endsWith(" test${ v.name.capitalize()} UnitTest" ) || task . path . endsWith( " test ${ v.name.capitalize() } " ) ) {
4349 return v
4450 }
4551 }
@@ -75,8 +81,8 @@ class AndroidGradleUtils {
7581 FileTree javaTree = project. fileTree(dir : javaDestinations, excludes : EXCLUDES )
7682
7783 FileTree destinationsTree
78- if ( project. plugins . findPlugin( ' kotlin-android ' ) != null ) {
79- def kotlinDestinations = " ${ project.buildDir } /tmp/kotlin-classes/ ${ variant.name } "
84+ def kotlinDestinations = " ${ project.buildDir } /tmp/ kotlin-classes/ ${ variant.name } "
85+ if ( Files . exists( Paths . get( kotlinDestinations))) {
8086 def kotlinTree = project. fileTree(dir : kotlinDestinations, excludes : EXCLUDES )
8187 destinationsTree = javaTree + kotlinTree
8288 } else {
0 commit comments