@@ -53,7 +53,7 @@ class AffectedModuleDetectorPlugin : Plugin<Project> {
5353 }
5454
5555 private fun registerJvmTests (project : Project ) {
56- registerAffectedTestTask(TestType .JvmTest (" runAffectedUnitTests" , TASK_GROUP_NAME , " Runs all affected unit tests" ), project)
56+ registerAffectedTestTask(TestType .AndroidJvmTest (" runAffectedUnitTests" , TASK_GROUP_NAME , " Runs all affected unit tests" ), project)
5757 }
5858
5959 private fun registerAffectedConnectedTestTask (rootProject : Project ) {
@@ -74,11 +74,11 @@ class AffectedModuleDetectorPlugin : Plugin<Project> {
7474
7575 rootProject.subprojects { project ->
7676 project.afterEvaluate {
77- val pluginIds = setOf (" com.android.application" , " com.android.library" , " java-library " , " kotlin" )
77+ val pluginIds = setOf (" com.android.application" , " com.android.library" , " java" , " kotlin" )
7878 pluginIds.forEach { pluginId ->
79- if (pluginId == " java-library " || pluginId == " kotlin" ) {
80- if (testType is TestType .JvmTest ) {
81- withPlugin(pluginId, task, testType, project)
79+ if (pluginId == " java" || pluginId == " kotlin" ) {
80+ if (testType is TestType .AndroidJvmTest ) {
81+ withPlugin(pluginId, task, TestType . JvmTest ( testType.name, testType.group, testType.description) , project)
8282 }
8383 } else {
8484 withPlugin(pluginId, task, testType, project)
@@ -117,7 +117,15 @@ class AffectedModuleDetectorPlugin : Plugin<Project> {
117117 return when (testType) {
118118 is TestType .RunAndroidTest -> getPathAndTask(project, tasks.runAndroidTestTask)
119119 is TestType .AssembleAndroidTest -> getPathAndTask(project, tasks.assembleAndroidTestTask)
120- is TestType .JvmTest -> getPathAndTask(project, tasks.jvmTestTask)
120+ is TestType .AndroidJvmTest -> getPathAndTask(project, tasks.jvmTestTask)
121+ is TestType .JvmTest -> {
122+ // if we are a jvm only module, run the "test" command by default unless a custom one is set
123+ if (tasks.jvmTestTask != AffectedTestConfiguration .DEFAULT_JVM_TEST_TASK ) {
124+ getPathAndTask(project, tasks.jvmTestTask)
125+ } else {
126+ getPathAndTask(project, " test" )
127+ }
128+ }
121129 }
122130 }
123131
@@ -166,6 +174,7 @@ class AffectedModuleDetectorPlugin : Plugin<Project> {
166174 internal sealed class TestType (open val name : String , open val group : String , open val description : String ) {
167175 data class RunAndroidTest (override val name : String , override val group : String , override val description : String ) : TestType(name, group, description)
168176 data class AssembleAndroidTest (override val name : String , override val group : String , override val description : String ) : TestType(name, group, description)
177+ data class AndroidJvmTest (override val name : String , override val group : String , override val description : String ) : TestType(name, group, description)
169178 data class JvmTest (override val name : String , override val group : String , override val description : String ) : TestType(name, group, description)
170179 }
171180
0 commit comments