From 3b57d8772ebe67511aa8d6982be7ca3f7fe389c6 Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Fri, 28 Jun 2024 12:53:55 +0300 Subject: [PATCH] Fix running ./gradlew tasks --- build.gradle.kts | 76 ++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 6d0392dcd967..36f6b373affd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -49,56 +49,56 @@ if (project.findProperty("skipTests") as String? == "true") { } } -tasks { - val listTestsInPartition by registering { - group = "Help" - description = "List test tasks in given partition" - - // total of 4 partitions (see modulo 4 below) - var testPartition = (project.findProperty("testPartition") as String?)?.toInt() - if (testPartition == null) { - throw GradleException("Test partition must be specified") - } else if (testPartition < 0 || testPartition >= 4) { - throw GradleException("Invalid test partition") - } +if (gradle.startParameter.taskNames.any { it.equals("listTestsInPartition") }) { + tasks { + val listTestsInPartition by registering { + group = "Help" + description = "List test tasks in given partition" + + // total of 4 partitions (see modulo 4 below) + var testPartition = (project.findProperty("testPartition") as String?)?.toInt() + if (testPartition == null) { + throw GradleException("Test partition must be specified") + } else if (testPartition < 0 || testPartition >= 4) { + throw GradleException("Invalid test partition") + } - val partitionTasks = ArrayList() - var testPartitionCounter = 0 - subprojects { - // relying on predictable ordering of subprojects - // (see https://docs.gradle.org/current/dsl/org.gradle.api.Project.html#N14CB4) - // since we are splitting these tasks across different github action jobs - val enabled = testPartitionCounter++ % 4 == testPartition - if (enabled) { - tasks.withType().configureEach { - partitionTasks.add(this) + val partitionTasks = ArrayList() + var testPartitionCounter = 0 + subprojects { + // relying on predictable ordering of subprojects + // (see https://docs.gradle.org/current/dsl/org.gradle.api.Project.html#N14CB4) + // since we are splitting these tasks across different github action jobs + val enabled = testPartitionCounter++ % 4 == testPartition + if (enabled) { + tasks.withType().configureEach { + partitionTasks.add(this) + } } } - } - doLast { - File("test-tasks.txt").printWriter().use { writer -> - partitionTasks.forEach { task -> - var taskPath = task.project.path + ":" + task.name - // smoke tests are run separately - // :instrumentation:test runs all instrumentation tests - if (taskPath != ":smoke-tests:test" && taskPath != ":instrumentation:test") { - writer.println(taskPath) + doLast { + File("test-tasks.txt").printWriter().use { writer -> + partitionTasks.forEach { task -> + var taskPath = task.project.path + ":" + task.name + // smoke tests are run separately + // :instrumentation:test runs all instrumentation tests + if (taskPath != ":smoke-tests:test" && taskPath != ":instrumentation:test") { + writer.println(taskPath) + } } } } - } - // disable all tasks to stop build - subprojects { - tasks.configureEach { - enabled = false + // disable all tasks to stop build + subprojects { + tasks.configureEach { + enabled = false + } } } } -} -if (gradle.startParameter.taskNames.any { it.equals("listTestsInPartition") }) { // disable all tasks to stop build project.tasks.configureEach { if (this.name != "listTestsInPartition") {