Skip to content

Commit 2909eb4

Browse files
Only require Java to be installed when using a Dafny version before 3.9 (#286)
1 parent 0def1dd commit 2909eb4

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

src/language/dafnyInstallation.ts

+19-14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as os from 'os';
22
import * as fs from 'fs';
33
import * as path from 'path';
44
import { promisify } from 'util';
5+
import { versionToNumeric } from '../ui/dafnyIntegration';
56

67
import { workspace, ExtensionContext, Uri, OutputChannel, FileSystemError, window } from 'vscode';
78
import { Utils } from 'vscode-uri';
@@ -212,25 +213,29 @@ export class DafnyInstaller {
212213
and restart VSCode, which may reinstall Dafny.`);
213214
return false;
214215
}
215-
try {
216-
const process = await this.execLog('javac -version');
217-
if(!(/javac \d+\.\d+/.exec(process.stdout))
218-
&& !(/javac \d+\.\d+/.exec(process.stderr))) {
219-
throw '';
216+
const configuredVersion = await getConfiguredVersion(this.context);
217+
if(versionToNumeric(configuredVersion) < versionToNumeric('3.9.0')) {
218+
try {
219+
220+
const process = await this.execLog('javac -version');
221+
if(!(/javac \d+\.\d+/.exec(process.stdout))
222+
&& !(/javac \d+\.\d+/.exec(process.stderr))) {
223+
throw '';
224+
}
225+
} catch(error: unknown) {
226+
const errorMsg = error === '' ? 'Javac not found' : `${error}`;
227+
this.writeStatus(`${errorMsg}. Javac is needed because you use a version of Dafny older than 3.9.0. Please install a valid JDK`
228+
+ ' and ensure that the path containing javac is in the PATH environment variable. '
229+
+ 'You can obtain a free open-source JDK 1.8 from here: '
230+
+ 'https://aws.amazon.com/corretto/');
231+
return false;
220232
}
221-
} catch(error: unknown) {
222-
const errorMsg = error === '' ? 'Javac not found' : `${error}`;
223-
this.writeStatus(`${errorMsg}. Please install a valid JDK`
224-
+ ' and ensure that the path containing javac is in the PATH environment variable. '
225-
+ 'You can obtain a free open-source JDK 1.8 from here: '
226-
+ 'https://aws.amazon.com/corretto/');
227-
return false;
228233
}
229234
await this.execLog(`git clone --recurse-submodules ${LanguageServerConstants.DafnyGitUrl}`);
230235
processChdir(Utils.joinPath(installationPath, 'dafny').fsPath);
231236
await this.execLog('git fetch --all --tags');
232-
await this.execLog(`git checkout v${await getConfiguredVersion(this.context)}`);
233-
await this.execLog('make exe');
237+
await this.execLog(`git checkout v${configuredVersion}`);
238+
await this.execLog('dotnet build Source/DafnyLanguageServer/DafnyLanguageServer.csproj');
234239
const binaries = Utils.joinPath(installationPath, 'dafny', 'Binaries').fsPath;
235240
processChdir(binaries);
236241
try {

src/ui/dafnyIntegration.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default async function createAndRegisterDafnyIntegration(
3737
await DafnyVersionView.createAndRegister(context, languageServerVersion);
3838
}
3939

40-
function versionToNumeric(version: string): number {
40+
export function versionToNumeric(version: string): number {
4141
const numbers = version.split('.').map(x => Number.parseInt(x));
4242
return ((numbers[0] * 1000) + numbers[1]) * 1000 + numbers[2];
4343
}

0 commit comments

Comments
 (0)