From 33ab25a557897e4823e6908dbbc5e325d787d633 Mon Sep 17 00:00:00 2001 From: Alex Hart Date: Mon, 6 Mar 2023 10:46:51 -0400 Subject: [PATCH] Add global formatter to gradle build files. --- build.gradle | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/build.gradle b/build.gradle index 3f58773e0..93079c267 100644 --- a/build.gradle +++ b/build.gradle @@ -84,3 +84,18 @@ task qa { task clean(type: Delete) { delete rootProject.buildDir } + +task format { + group 'Formatting' + description 'Runs the ktlint formatter on all sources in this project and included builds' + + def dependencyList = subprojects.collect { + tasks.findByPath(":${it.name}:ktlintFormat") + } + + dependencyList.removeIf { it == null} + dependencyList.add(0, gradle.includedBuild('build-logic').task(':plugins:ktlintFormat')) + dependencyList.add(0, gradle.includedBuild('build-logic').task(':tools:ktlintFormat')) + + dependsOn dependencyList +} \ No newline at end of file