From 2ec94082e3c02ada79c9705ee03965c4c48b2424 Mon Sep 17 00:00:00 2001 From: Don Turner Date: Tue, 21 May 2024 17:21:47 +0100 Subject: [PATCH] Remove the printModulePaths task and read modules direct from settings Change-Id: Ib871afb7e9f5da3a4240e18062fad9e701c218e7 --- build.gradle.kts | 10 ---------- generateModuleGraphs.sh | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 1790cd202..38778e100 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -49,13 +49,3 @@ plugins { alias(libs.plugins.room) apply false alias(libs.plugins.module.graph) apply true // Plugin applied to allow module graph generation } - -// Task to print all the module paths in the project e.g. :core:data -// Used by module graph generator script -tasks.register("printModulePaths") { - subprojects { - if (subprojects.size == 0) { - println(this.path) - } - } -} \ No newline at end of file diff --git a/generateModuleGraphs.sh b/generateModuleGraphs.sh index fb2d74712..b86d54412 100755 --- a/generateModuleGraphs.sh +++ b/generateModuleGraphs.sh @@ -31,6 +31,19 @@ then exit 1 fi +# Check for a version of grep which supports Perl regex. +# On MacOS the OS installed grep doesn't support Perl regex so check for the existence of the +# GNU version instead which is prefixed with 'g' to distinguish it from the OS installed version. + if grep -P "" /dev/null > /dev/null 2>&1; then + GREP_COMMAND=grep +elif command -v ggrep &> /dev/null; then + GREP_COMMAND=ggrep +else + echo "You don't have a version of 'grep' installed which supports Perl regular expressions." + echo "On MacOS you can install one using Homebrew with the command: 'brew install grep'" + exit 1 +fi + # Initialize an array to store excluded modules excluded_modules=() @@ -50,7 +63,7 @@ while [[ $# -gt 0 ]]; do done # Get the module paths -module_paths=$(./gradlew -q printModulePaths --no-configuration-cache) +module_paths=$(${GREP_COMMAND} -oP 'include\("\K[^"]+' settings.gradle.kts) # Ensure the output directory exists mkdir -p docs/images/graphs/