Skip to content

Commit

Permalink
Dynamically remove the Equinox launcher fragment for macOS x86_64.
Browse files Browse the repository at this point in the history
Signed-off-by: Roland Grunberg <[email protected]>
  • Loading branch information
rgrunber committed Feb 13, 2024
1 parent 176339e commit da501cd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as fs from 'fs';
import * as fse from 'fs-extra';
import * as os from 'os';
import * as path from 'path';
import * as semver from 'semver';
import { CodeActionContext, commands, ConfigurationTarget, Diagnostic, env, EventEmitter, ExtensionContext, extensions, IndentAction, InputBoxOptions, languages, QuickPickItemKind, RelativePattern, TextDocument, TextEditorRevealType, UIKind, Uri, ViewColumn, window, workspace, WorkspaceConfiguration } from 'vscode';
import { CancellationToken, CodeActionParams, CodeActionRequest, Command, CompletionRequest, DidChangeConfigurationNotification, ExecuteCommandParams, ExecuteCommandRequest, LanguageClientOptions, RevealOutputChannelOn } from 'vscode-languageclient';
import { LanguageClient } from 'vscode-languageclient/node';
Expand All @@ -13,7 +14,7 @@ import { ClientErrorHandler } from './clientErrorHandler';
import { Commands, CommandTitle } from './commands';
import { ClientStatus, ExtensionAPI, TraceEvent } from './extension.api';
import * as fileEventHandler from './fileEventHandler';
import { getSharedIndexCache, HEAP_DUMP_LOCATION, prepareExecutable } from './javaServerStarter';
import { getSharedIndexCache, HEAP_DUMP_LOCATION, prepareExecutable, removeEquinoxFragmentOnDarwinX64 } from './javaServerStarter';
import { initializeLogFile, logger } from './log';
import { cleanupLombokCache } from "./lombokSupport";
import { markdownPreviewProvider } from "./markdownPreviewProvider";
Expand All @@ -30,6 +31,7 @@ import { JavaClassEditorProvider } from './javaClassEditor';
import { StandardLanguageClient } from './standardLanguageClient';
import { SyntaxLanguageClient } from './syntaxLanguageClient';
import { convertToGlob, deleteClientLog, deleteDirectory, ensureExists, getBuildFilePatterns, getExclusionGlob, getInclusionPatternsFromNegatedExclusion, getJavaConfig, getJavaConfiguration, hasBuildToolConflicts, resolveActualCause } from './utils';
import glob = require('glob');
import { Telemetry } from './telemetry';
import { getMessage } from './errorUtils';
import { TelemetryService } from '@redhat-developer/vscode-redhat-telemetry/lib';
Expand All @@ -38,7 +40,6 @@ import { loadSupportedJreNames } from './jdkUtils';
import { BuildFileSelector, PICKED_BUILD_FILES, cleanupProjectPickerCache } from './buildFilesSelector';
import { pasteFile } from './pasteAction';
import { ServerStatusKind } from './serverStatus';
import glob = require('glob');

const syntaxClient: SyntaxLanguageClient = new SyntaxLanguageClient();
const standardClient: StandardLanguageClient = new StandardLanguageClient();
Expand Down Expand Up @@ -139,6 +140,17 @@ export async function activate(context: ExtensionContext): Promise<ExtensionAPI>

cleanJavaWorkspaceStorage();

// https://github.com/redhat-developer/vscode-java/issues/3484
if (process.platform === 'darwin' && process.arch === 'x64') {
try {
if (semver.lt(os.release(), '20.0.0')) {
removeEquinoxFragmentOnDarwinX64(context);
}
} catch (error) {
// do nothing
}
}

return requirements.resolveRequirements(context).catch(error => {
// show error
window.showErrorMessage(error.message, error.label).then((selection) => {
Expand Down
13 changes: 12 additions & 1 deletion src/javaServerStarter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import * as fs from 'fs';
import * as fse from 'fs-extra';
import * as glob from 'glob';
import * as net from 'net';
import * as os from 'os';
Expand All @@ -9,7 +10,7 @@ import { Executable, ExecutableOptions, StreamInfo, TransportKind } from 'vscode
import { logger } from './log';
import { addLombokParam, isLombokSupportEnabled } from './lombokSupport';
import { RequirementsData } from './requirements';
import { getJavaagentFlag, getJavaEncoding, getKey, isInWorkspaceFolder, IS_WORKSPACE_VMARGS_ALLOWED } from './settings';
import { IS_WORKSPACE_VMARGS_ALLOWED, getJavaEncoding, getJavaagentFlag, getKey, isInWorkspaceFolder } from './settings';
import { deleteDirectory, ensureExists, getJavaConfiguration, getTimestamp } from './utils';

// eslint-disable-next-line no-var
Expand Down Expand Up @@ -316,3 +317,13 @@ export function parseVMargs(params: any[], vmargsLine: string) {
}
});
}

export function removeEquinoxFragmentOnDarwinX64(context: ExtensionContext) {
// https://github.com/redhat-developer/vscode-java/issues/3484
const extensionPath = context.extensionPath;
const matches = new glob.GlobSync(`${extensionPath}/server/plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64*.jar`).found;
for (const fragment of matches) {
fse.removeSync(fragment);
logger.info(`Removing Equinox launcher fragment : ${fragment}`);
}
}

0 comments on commit da501cd

Please sign in to comment.