From b96435ac02659985e7e3083723bd32ce189b62a8 Mon Sep 17 00:00:00 2001 From: Eyal LEZMY Date: Fri, 20 Oct 2023 16:44:02 +0200 Subject: [PATCH] [Build] Reinforce the Gradle configuration for sample folder selection In the project, a folder walk is done to list all the "samples" folders. This is done by checking the path in the settings.gradle.kts file. The path provided in the filter logic can be absolute and in this case it can include parents folders names, which can corrupt the check. Example: My project is cloned in the following folder: `/android/samples/platform-samples` Then all the folders will be considered as samples and the Gradle build will failed at configuration step. Solution: Remove the parents folders part in the path during the filtering if the path is absolute. --- settings.gradle.kts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 8be94b01..459614a5 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -57,7 +57,14 @@ if (samples.isEmpty()) { // Find all build.gradle files under samples folder settingsDir.walk() .filter { it.name == "build.gradle" || it.name == "build.gradle.kts" } - .filter { it.path.contains("${separator}samples${separator}") } + .filter { + val relativePath = if (it.isAbsolute) { + it.path.substring(settingsDir.path.length) + } else { + it.path + } + relativePath.contains("${separator}samples${separator}") + } .map { it.parent.substring(rootDir.path.length) } .forEach { add(it.replace(separator, ":"))