diff --git a/src/extension.ts b/src/extension.ts index 6c60d0efa..87af408ef 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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'; @@ -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"; @@ -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'; @@ -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(); @@ -139,6 +140,17 @@ export async function activate(context: ExtensionContext): Promise 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) => { diff --git a/src/javaServerStarter.ts b/src/javaServerStarter.ts index c69d334e2..042792da2 100644 --- a/src/javaServerStarter.ts +++ b/src/javaServerStarter.ts @@ -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'; @@ -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 @@ -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}`); + } +}