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

fix: set GradleExecution jdk use java.import.gradle.java.home #1491

Merged
merged 36 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
343a6b7
merge
Jiaaming Apr 29, 2024
c78ddd4
Merge branch 'develop' of https://github.com/Jiaaming/vscode-gradle i…
Jiaaming Apr 29, 2024
18cb0de
Merge branch 'develop' of https://github.com/Jiaaming/vscode-gradle i…
Jiaaming May 11, 2024
8b48ce5
init new daemon ts class
Jiaaming May 13, 2024
9db21b5
finished basic getGradleStatus demo
Jiaaming May 13, 2024
a98d3b7
add wrapper & local installation get gradle status
Jiaaming May 13, 2024
f9060ec
finish stop daemon task in typescript
Jiaaming May 13, 2024
f597275
finish stop all daemons in typescript
Jiaaming May 14, 2024
2530ae6
format code lint
Jiaaming May 14, 2024
f48ba66
Merge branch 'develop' into revert-gd
Jiaaming May 14, 2024
ccbe159
lint and format
Jiaaming May 14, 2024
79d3e7b
format code lint
Jiaaming May 14, 2024
d12592d
add gradle daemon test and fix minors
Jiaaming May 14, 2024
de30aff
fix import bugs
Jiaaming May 14, 2024
64af954
fix test case
Jiaaming May 16, 2024
9a49ad6
fix minor bugs
Jiaaming May 16, 2024
63b2679
fix minors
Jiaaming May 16, 2024
a99a188
finish basic test cases for gradle daemons
Jiaaming May 16, 2024
905f81b
update gradle daemons & test cases
Jiaaming May 16, 2024
22e84c7
update gradle daemons & test cases
Jiaaming May 16, 2024
2337a96
update task server impl
Jiaaming May 20, 2024
4fcf41f
fix import error
Jiaaming May 20, 2024
88b645b
fix lint
Jiaaming May 20, 2024
7c7a9bb
fix daemon status bugs and add test
Jiaaming May 21, 2024
6e36030
fix daemon status bugs and add test
Jiaaming May 21, 2024
8cc0eca
Merge branch 'microsoft:develop' into revert-gd
Jiaaming May 21, 2024
d64fbbc
Merge branch 'microsoft:develop' into revert-gd
Jiaaming May 27, 2024
71705d9
fix jdk bugs
Jiaaming May 27, 2024
eae01d6
Merge branch 'revert-gd' of https://github.com/Jiaaming/vscode-gradle…
Jiaaming May 27, 2024
ac109a2
fix gradle daemon status jdk bugs
Jiaaming May 28, 2024
21c8faf
fix bugs
Jiaaming May 28, 2024
1daab91
fix gradle daemon jdk bugs
Jiaaming May 28, 2024
db0d9c3
change gradle daemons log method
Jiaaming May 28, 2024
1c07050
fix lint
Jiaaming May 28, 2024
c16318b
fix lint
Jiaaming May 28, 2024
03206f3
add detail logger
Jiaaming May 29, 2024
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { GradleExecution } from "./GradleExecution";
import { execAsync } from "../../../util/execAsync";
import { getConfigJavaImportGradleJavaHome } from "../../../util/config";
import { logger } from "../../../logger";

export class GradleLocalInstallation implements GradleExecution {
private gradleHomePath: string;

Expand All @@ -15,13 +18,17 @@ export class GradleLocalInstallation implements GradleExecution {
const command = `${this.gradleHomePath} ${args.join(" ")}`;

try {
const { stdout, stderr } = await execAsync(command);
const jdkPath = getConfigJavaImportGradleJavaHome();
const env = jdkPath ? { ...process.env, JAVA_HOME: jdkPath } : process.env;

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

export class GradleWrapper implements GradleExecution {
private gradleWrapperPath: string;

constructor(private projectRoot: string) {
const wrapperName = process.platform === "win32" ? "gradlew.bat" : "gradlew";
this.gradleWrapperPath = path.join(projectRoot, wrapperName);
Expand All @@ -17,12 +20,16 @@ export class GradleWrapper implements GradleExecution {

const command = `${this.gradleWrapperPath} ${args.join(" ")}`;
try {
const { stdout, stderr } = await execAsync(command, { cwd: this.projectRoot });
const jdkPath = getConfigJavaImportGradleJavaHome();
const env = jdkPath ? { ...process.env, JAVA_HOME: jdkPath } : process.env;

const { stdout, stderr } = await execAsync(command, { cwd: this.projectRoot, env });
if (stderr) {
throw new Error(`Error running gradle wrapper: ${stderr}`);
logger.error(stderr);
}
return stdout;
} catch (error) {
logger.error(error.message);
throw new Error(`Error running gradle wrapper: ${error.message}`);
}
}
Expand Down
Loading