Skip to content
Open
Show file tree
Hide file tree
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
18 changes: 18 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,31 @@ async function getJavaExtensionAPI(): Promise<JavaExtensionAPI> {
if (!vscodeJava) {
throw new Error("VSCode java is not installed");
}
const javaVersion: string = (vscodeJava.packageJSON as Record<string, unknown>).version as string ?? "";
if (javaVersion && isJavaVersionIncompatible(javaVersion)) {
window.showWarningMessage(
localize("redhat.java.version.incompatible", javaVersion),
localize("redhat.java.version.incompatible.open"),
localize("redhat.java.version.incompatible.dismiss")
).then(selection => {
if (selection === localize("redhat.java.version.incompatible.open")) {
commands.executeCommand("extension.open", JAVA_EXTENSION_ID);
}
});
}
const api = await vscodeJava.activate();
if (!api) {
throw new Error("VSCode java api not found");
}
return Promise.resolve(api);
}

function isJavaVersionIncompatible(version: string): boolean {
const parts = version.split(".").map(p => parseInt(p, 10));
const [major = 0, minor = 0] = parts;
return major > 1 || (major === 1 && minor >= 55);
}

async function handleWorkspaceSaveInProgress(context: vscode.ExtensionContext): Promise<boolean> {
const projectProvider = getProjectProvider(context);
const wip = projectProvider.getContext().globalState.get('workspaceSaveInProgress');
Expand Down
5 changes: 4 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,8 @@
"hotkey.commands.title.add.project": "Liberty: Add Project to Liberty Tools",
"hotkey.commands.title.remove.project": "Liberty: Remove Project from Liberty Tools",
"hotkey.commands.title.show.commands": "Liberty: Show Liberty commands",
"workspace.not.saved.projects.may.not.persist": "Save the workspace first. Projects that you manually add to Liberty Tools might not persist in the next VS Code session if you don't save the workspace before you add the project."
"workspace.not.saved.projects.may.not.persist": "Save the workspace first. Projects that you manually add to Liberty Tools might not persist in the next VS Code session if you don't save the workspace before you add the project.",
"redhat.java.version.incompatible": "Liberty Tools: The installed 'Language Support for Java' extension (v{0}) is not compatible with this version of Liberty Tools. Jakarta EE diagnostics and quick-fixes will not work correctly. Downgrade 'Language Support for Java' to v1.54.0.",
"redhat.java.version.incompatible.open": "View in Marketplace",
"redhat.java.version.incompatible.dismiss": "Dismiss"
}
14 changes: 14 additions & 0 deletions src/test/resources/ci/scripts/exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ VSCODE_VERSION_TO_RUN=$2
#Build tool to test (maven or gradle)
BUILD_TOOL=${3:-gradle}

# Pinned version of redhat.java that is compatible with Liberty Tools (lsp4jakarta)
REDHAT_JAVA_VERSION="1.54.0"

# Current time.
currentTime=(date +"%Y/%m/%d-%H:%M:%S:%3N")

Expand Down Expand Up @@ -51,6 +54,7 @@ main() {

#Initialisation step
npm run test-compile
installPinnedRedhatJava

# Initialize Maven project if needed
if [ "$BUILD_TOOL" = "maven" ]; then
Expand Down Expand Up @@ -116,6 +120,16 @@ main() {
fi
}

# Download and install a pinned version of redhat.java from Open VSX to avoid
# pulling 1.55.0+ which is incompatible with lsp4jakarta used by Liberty Tools.
installPinnedRedhatJava() {
local vsix_url="https://open-vsx.org/api/redhat/java/${REDHAT_JAVA_VERSION}/file/redhat.java-${REDHAT_JAVA_VERSION}.vsix"
local vsix_file="/tmp/redhat.java-${REDHAT_JAVA_VERSION}.vsix"
echo "> $(${currentTime[@]}): Installing pinned redhat.java v${REDHAT_JAVA_VERSION} from Open VSX"
curl -fL "$vsix_url" -o "$vsix_file"
npx extest install-vsix "$vsix_file"
}

#start docker and display
startDisplayAndDocker() {
# Tell the terminal session to use display port 88.
Expand Down
4 changes: 2 additions & 2 deletions src/util/javaServerStarter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import * as glob from 'glob';
import {JAKARTA_LS_JAR, LIBERTY_LS_JAR} from '../extension'

const DEBUG = startedInDebugMode();
const LIBERTY_LS_DEBUG_PORT = 8002;
const JAKARTA_LS_DEBUG_PORT = 8003;
const LIBERTY_LS_DEBUG_PORT = 0;
const JAKARTA_LS_DEBUG_PORT = 0;

// Referenced:
// https://github.com/redhat-developer/vscode-microprofile/blob/master/src/languageServer/javaServerStarter.ts
Expand Down
Loading