From 648d5bc5e86bf81481359e35534dd95ee4574b73 Mon Sep 17 00:00:00 2001 From: Sergey Chelombitko Date: Fri, 2 Aug 2024 20:44:50 +0100 Subject: [PATCH] Use Kotlin DSL extensions --- .../kotlin/com/malinskiy/marathon/MarathonPlugin.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/MarathonPlugin.kt b/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/MarathonPlugin.kt index 2ac265eb1..ab6887582 100644 --- a/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/MarathonPlugin.kt +++ b/marathon-gradle-plugin/src/main/kotlin/com/malinskiy/marathon/MarathonPlugin.kt @@ -13,6 +13,9 @@ import org.gradle.api.Plugin 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 class MarathonPlugin : Plugin { override fun apply(project: Project) { @@ -31,10 +34,10 @@ class MarathonPlugin : Plugin { } private fun Project.configureRootProject() { - val marathonConfig = extensions.create(MarathonExtension.NAME, MarathonExtension::class.java) + val marathonConfig = extensions.create(MarathonExtension.NAME) marathonConfig.initDefaults() - tasks.register(WORKER_TASK_NAME, MarathonWorkerRunTask::class.java) + tasks.register(WORKER_TASK_NAME) gradle.projectsEvaluated { val outputDir = layout.buildDirectory.dir("reports/marathon").get().asFile @@ -49,7 +52,7 @@ class MarathonPlugin : Plugin { description = "Runs all the instrumentation test variations on all the connected devices" } - val marathonWorkerTask = rootProject.tasks.named(WORKER_TASK_NAME, MarathonWorkerRunTask::class.java) + val marathonWorkerTask = rootProject.tasks.named(WORKER_TASK_NAME) val androidComponents = extensions.getByType(AndroidComponentsExtension::class.java) androidComponents.onVariants { variant -> variant.components @@ -66,7 +69,7 @@ class MarathonPlugin : Plugin { testComponent: Component, marathonWorkerTask: TaskProvider ): TaskProvider = - tasks.register(variant.computeTaskName(TASK_PREFIX, "androidTest"), MarathonScheduleTestsToWorkerTask::class.java) { + tasks.register(variant.computeTaskName(TASK_PREFIX, "androidTest")) { group = JavaBasePlugin.VERIFICATION_GROUP description = "Runs instrumentation tests on all the connected devices for '${variant.name}' " + "variation and generates a report with screenshots"