From 847af344638db958c1a9c308b3824170722f6616 Mon Sep 17 00:00:00 2001 From: Jendrik Johannes Date: Mon, 14 Oct 2024 12:06:52 +0200 Subject: [PATCH] Discover Gradle builds by looking for setting.gradle(.kts) When the option 'gradle.nestedProjects: true' is set, the build roots are currently discovered by looking for the wrapper scripts. These however are completely optional for a build. But there is one thing each Gradle build definitely needs to have: A 'settings.gradle' or 'setting.gradle.kts' file. Gradle itself searches for these files to accept a folder as a Gradle build/project. This change proposes to check for these files instead of the gradlw scripts. A good project to test this with is https://github.com/microsoft/build-server-for-gradle which contains a lot of Gradle build in the 'testProjects' folder. Signed-off-by: Jendrik Johannes --- extension/src/stores/RootProjectsStore.ts | 2 +- extension/src/util/index.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extension/src/stores/RootProjectsStore.ts b/extension/src/stores/RootProjectsStore.ts index f694e8b6e..2f07a6f89 100644 --- a/extension/src/stores/RootProjectsStore.ts +++ b/extension/src/stores/RootProjectsStore.ts @@ -7,7 +7,7 @@ import { RootProject } from "../rootProject/RootProject"; import { GRADLE_BUILD_FILE_NAMES } from "../constant"; async function getNestedRootProjectFolders(): Promise { - const matchingNestedWrapperFiles = await vscode.workspace.findFiles("**/{gradlew,gradlew.bat}"); + const matchingNestedWrapperFiles = await vscode.workspace.findFiles("**/{settings.gradle,settings.gradle.kts}"); return [...new Set(matchingNestedWrapperFiles.map((uri) => path.dirname(uri.fsPath)))]; } diff --git a/extension/src/util/index.ts b/extension/src/util/index.ts index 27d9ba0ef..cf05ca677 100644 --- a/extension/src/util/index.ts +++ b/extension/src/util/index.ts @@ -57,8 +57,8 @@ export function waitOnTcp(host: string, port: number): Promise { export function isGradleRootProject(rootProject: RootProject): boolean { return ( - fs.existsSync(path.join(rootProject.getProjectUri().fsPath, "gradlew")) || - fs.existsSync(path.join(rootProject.getProjectUri().fsPath, "gradlew.bat")) + fs.existsSync(path.join(rootProject.getProjectUri().fsPath, "settings.gradle")) || + fs.existsSync(path.join(rootProject.getProjectUri().fsPath, "settings.gradle.kts")) ); }