Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discover Gradle builds by looking for setting.gradle(.kts) #1618

Merged
merged 3 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extension/src/stores/RootProjectsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { RootProject } from "../rootProject/RootProject";
import { GRADLE_BUILD_FILE_NAMES } from "../constant";

async function getNestedRootProjectFolders(): Promise<string[]> {
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)))];
}

Expand Down
4 changes: 2 additions & 2 deletions extension/src/test/testUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ export function stubWorkspaceFolders(workspaceFolders: vscode.WorkspaceFolder[])
const getWorkspaceFolderStub = sinon.stub(vscode.workspace, "getWorkspaceFolder");
const dirnameStub = sinon.stub(path, "dirname");
workspaceFolders.forEach((workspaceFolder) => {
existsSyncStub.withArgs(path.join(workspaceFolder.uri.fsPath, "gradlew")).returns(true);
existsSyncStub.withArgs(path.join(workspaceFolder.uri.fsPath, "settings.gradle")).returns(true);
getWorkspaceFolderStub.withArgs(sinon.match.has("fsPath", workspaceFolder.uri.fsPath)).returns(workspaceFolder);
dirnameStub.withArgs(workspaceFolder.uri.fsPath).returns(workspaceFolder.uri.fsPath);
});
sinon
.stub(vscode.workspace, "findFiles")
.withArgs("**/{gradlew,gradlew.bat}")
.withArgs("**/{settings.gradle,settings.gradle.kts}")
.returns(Promise.resolve(workspaceFolders.map((folder) => folder.uri)));
}

Expand Down
4 changes: 2 additions & 2 deletions extension/src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export function waitOnTcp(host: string, port: number): Promise<void> {

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"))
);
}

Expand Down
Loading