@@ -8,6 +8,9 @@ import org.gradle.api.logging.Logger
8
8
import org.gradle.api.logging.Logging
9
9
import org.gradle.api.tasks.testing.Test
10
10
11
+ import java.nio.file.Files
12
+ import java.nio.file.Paths
13
+
11
14
class AndroidGradleUtils {
12
15
13
16
private static final Logger LOGGER = Logging . getLogger(AndroidGradleUtils )
@@ -29,7 +32,10 @@ class AndroidGradleUtils {
29
32
}
30
33
31
34
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' )
33
39
34
40
def variants
35
41
if (androidPlugin. class. simpleName == ' LibraryPlugin' ) {
@@ -39,7 +45,7 @@ class AndroidGradleUtils {
39
45
}
40
46
41
47
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() } " ) ) {
43
49
return v
44
50
}
45
51
}
@@ -75,8 +81,8 @@ class AndroidGradleUtils {
75
81
FileTree javaTree = project. fileTree(dir : javaDestinations, excludes : EXCLUDES )
76
82
77
83
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))) {
80
86
def kotlinTree = project. fileTree(dir : kotlinDestinations, excludes : EXCLUDES )
81
87
destinationsTree = javaTree + kotlinTree
82
88
} else {
0 commit comments