Skip to content

Commit

Permalink
fix gradle daemon jdk bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiaaming committed May 28, 2024
1 parent 21c8faf commit 1daab91
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { GradleExecution } from "./GradleExecution";
import { execAsync } from "../../../util/execAsync";
import { getConfigJavaImportGradleJavaHome } from "../../../util/config";
import * as vscode from "vscode";

export class GradleLocalInstallation implements GradleExecution {
private gradleHomePath: string;

private outputChannel: vscode.OutputChannel;
constructor(gradleHomePath: string) {
this.gradleHomePath = gradleHomePath;
}
Expand All @@ -22,11 +23,12 @@ export class GradleLocalInstallation implements GradleExecution {

const { stdout, stderr } = await execAsync(command, { env });
if (stderr) {
throw new Error(`Error running gradle: ${stderr}`);
this.outputChannel.appendLine(`${stderr}`);
this.outputChannel.show();
}
return stdout;
} catch (error) {
throw new Error(`Error running gradle: ${error.message}`);
throw new Error(`Error running gradle local installation: ${error.message}`);
}
}
}
16 changes: 7 additions & 9 deletions extension/src/views/gradleDaemons/services/GradleWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import { execAsync } from "../../../util/execAsync";
import { GradleExecution } from "./GradleExecution";
import * as path from "path";
import { getConfigJavaImportGradleJavaHome } from "../../../util/config";
import { logger } from "../../../logger";
import * as vscode from "vscode";

export class GradleWrapper implements GradleExecution {
private gradleWrapperPath: string;
private outputChannel: vscode.OutputChannel;

constructor(private projectRoot: string) {
const wrapperName = process.platform === "win32" ? "gradlew.bat" : "gradlew";
this.gradleWrapperPath = path.join(projectRoot, wrapperName);
this.outputChannel = vscode.window.createOutputChannel("Gradle Wrapper");
}

public async exec(args: string[]): Promise<string> {
Expand All @@ -23,14 +27,8 @@ export class GradleWrapper implements GradleExecution {

const { stdout, stderr } = await execAsync(command, { cwd: this.projectRoot, env });
if (stderr) {
const stderrLines = stderr.split('\n');
const isError = stderrLines.some(line => line.toLowerCase().includes('error'));

if (isError) {
throw new Error(`Error running gradle wrapper: ${stderr}`);
} else {
logger.warn(`Warning: ${stderr}`);
}
this.outputChannel.appendLine(`${stderr}`);
this.outputChannel.show();
}
return stdout;
} catch (error) {
Expand Down

0 comments on commit 1daab91

Please sign in to comment.