Skip to content

Commit

Permalink
Add support for isolated projects (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
technoir42 authored Sep 11, 2024
1 parent c33274a commit fc2eb26
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import org.gradle.api.Project
import org.gradle.api.plugins.JavaBasePlugin
import org.gradle.api.tasks.TaskProvider
import org.gradle.kotlin.dsl.create
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dsl.registerIfAbsent

Expand Down Expand Up @@ -52,22 +51,20 @@ class MarathonPlugin : Plugin<Project> {
description = "Runs all the instrumentation test variations on all the connected devices"
}

val marathonWorkerTask = rootProject.tasks.named<MarathonWorkerRunTask>(WORKER_TASK_NAME)
val androidComponents = extensions.getByType(AndroidComponentsExtension::class.java)
androidComponents.onVariants { variant ->
variant.components
.filter { it is GeneratesTestApk }
.forEach { component ->
val testTask = registerTestTask(variant, component, marathonWorkerTask)
val testTask = registerTestTask(variant, component)
marathonTask.configure { dependsOn(testTask) }
}
}
}

private fun Project.registerTestTask(
variant: Variant,
testComponent: Component,
marathonWorkerTask: TaskProvider<MarathonWorkerRunTask>
testComponent: Component
): TaskProvider<MarathonScheduleTestsToWorkerTask> =
tasks.register<MarathonScheduleTestsToWorkerTask>(variant.computeTaskName(TASK_PREFIX, "androidTest")) {
group = JavaBasePlugin.VERIFICATION_GROUP
Expand All @@ -83,7 +80,7 @@ class MarathonPlugin : Plugin<Project> {
is TestVariant -> testedApkDir.set(variant.testedApks)
}

finalizedBy(marathonWorkerTask)
finalizedBy("${Project.PATH_SEPARATOR}$WORKER_TASK_NAME")
}

companion object {
Expand Down
1 change: 1 addition & 0 deletions sample/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ org.gradle.caching=true
org.gradle.configuration-cache=true
org.gradle.jvmargs=-Xmx8g -XX:+UseParallelGC
org.gradle.parallel=true
org.gradle.unsafe.isolated-projects=true
kotlin.daemon.jvmargs=-Xmx1g -XX:+UseParallelGC

android.useAndroidX=true

0 comments on commit fc2eb26

Please sign in to comment.