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

FISH-9450 Payara Tools for VSCode fails to pass environmental variables and start a Payara Micro instance #240

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
24 changes: 15 additions & 9 deletions src/main/fish/payara/project/Maven.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,28 +293,34 @@ export class Maven implements Build {
'-Dplatform=micro'
];

let process: ChildProcess = cp.spawn(mavenExe, cmdArgs, { cwd: project.targetFolder?.fsPath });
let jdkHome;
let env = { ...process.env };
if (this.payaraInstance && (jdkHome = this.payaraInstance.getJDKHome())) {
env['JAVA_HOME'] = jdkHome;
}

let childProcess: ChildProcess = cp.spawn(mavenExe, cmdArgs, { cwd: project.targetFolder?.fsPath, shell: true, env: env });

if (process.pid) {
if (childProcess.pid) {
let outputChannel = ProjectOutputWindowProvider.getInstance().get(`${project.artifactId}`);
outputChannel.show(false);
let logCallback = (data: string | Buffer): void => outputChannel.append(data.toString());
if (process.stdout !== null) {
process.stdout.on('data', logCallback);
if (childProcess.stdout !== null) {
childProcess.stdout.on('data', logCallback);
}
if (process.stderr !== null) {
process.stderr.on('data', logCallback);
if (childProcess.stderr !== null) {
childProcess.stderr.on('data', logCallback);
}
process.on('error', (err: Error) => {
childProcess.on('error', (err: Error) => {
console.log('error: ' + err.message);
});
process.on('exit', (code: number) => {
childProcess.on('exit', (code: number) => {
if (code === 0 && project.targetFolder && project.artifactId) {
callback(vscode.Uri.file(path.join(project.targetFolder.fsPath, project.artifactId)));
}
});
}
return process;
return childProcess;
}

public startPayaraMicro(
Expand Down