@@ -22,14 +22,12 @@ import * as https from 'https';
22
22
import * as child_process from 'child_process' ;
23
23
import * as vscode from 'vscode' ;
24
24
import * as crypto from 'crypto' ;
25
+ import { OPEN_JDK_VERSION_DOWNLOAD_LINKS , ORACLE_JDK_BASE_DOWNLOAD_URL , ORACLE_JDK_DOWNLOAD_VERSIONS } from './constants' ;
25
26
import { handleLog } from './extension' ;
26
27
import { promisify } from 'util' ;
27
28
28
29
let customView : vscode . WebviewPanel ;
29
30
let logger : vscode . OutputChannel ;
30
- let jdkConfContent : any ;
31
- const JDK_DOWNLOADER_CONF_FILE_PATH = "https://raw.githubusercontent.com/oracle/javavscode/main/vscode/src/jdkDownloaderManagement.json" ;
32
-
33
31
34
32
export const calculateChecksum = async ( filePath : string ) : Promise < string > => {
35
33
const ALGORITHM = 'sha256' ;
@@ -73,14 +71,8 @@ export const fetchDropdownOptions = async () => {
73
71
}
74
72
75
73
// Fetch version of the JDK available
76
- let versions ;
77
- try {
78
- const res = await axios . get ( JDK_DOWNLOADER_CONF_FILE_PATH , { timeout : 4000 } ) ;
79
- versions = await res . data ;
80
- } catch ( err : any ) {
81
- vscode . window . showErrorMessage ( "Error fetching JDK download versions" ) ;
82
- handleLog ( logger , err ?. messge ) ;
83
- }
74
+ const versions = ORACLE_JDK_DOWNLOAD_VERSIONS ;
75
+
84
76
return { machineArch, osType, versions } ;
85
77
}
86
78
@@ -97,7 +89,6 @@ export async function openJDKSelectionView(log: vscode.OutputChannel) {
97
89
) ;
98
90
logger = log ;
99
91
const { machineArch, osType, versions } = await fetchDropdownOptions ( ) ;
100
- jdkConfContent = versions ;
101
92
customView . webview . html = fetchJDKDownloadView ( machineArch , osType , versions ) ;
102
93
103
94
customView . webview . onDidReceiveMessage ( async message => {
@@ -123,13 +114,21 @@ export function JDKDownloader(JDKType: string, osType: string, osArchitecture: s
123
114
let downloadUrl : string = '' ;
124
115
125
116
// Generate download url on the basis of the jdk type chosen
126
- const { baseDownloadUrl } = JDKType === 'OpenJDK' ? jdkConfContent . openJdk [ `${ JDKVersion } ` ] : jdkConfContent . oracleJdk [ `${ JDKVersion } ` ] ;
127
-
128
- if ( osType === 'windows' ) {
129
- downloadUrl = `${ baseDownloadUrl } _${ osType . toLowerCase ( ) } -${ osArchitecture } _bin.zip` ;
117
+ if ( JDKType === 'OpenJDK' ) {
118
+ if ( osType === 'windows' ) {
119
+ downloadUrl = `${ OPEN_JDK_VERSION_DOWNLOAD_LINKS [ `${ JDKVersion } ` ] } _${ osType . toLowerCase ( ) } -${ osArchitecture } _bin.zip` ;
120
+ }
121
+ else {
122
+ downloadUrl = `${ OPEN_JDK_VERSION_DOWNLOAD_LINKS [ `${ JDKVersion } ` ] } _${ osType . toLowerCase ( ) } -${ osArchitecture } _bin.tar.gz` ;
123
+ }
130
124
}
131
- else {
132
- downloadUrl = `${ baseDownloadUrl } _${ osType . toLowerCase ( ) } -${ osArchitecture } _bin.tar.gz` ;
125
+ else if ( JDKType === 'Oracle JDK' ) {
126
+ if ( osType === 'windows' ) {
127
+ downloadUrl = `${ ORACLE_JDK_BASE_DOWNLOAD_URL } /${ JDKVersion } /latest/jdk-${ JDKVersion } _${ osType . toLowerCase ( ) } -${ osArchitecture } _bin.zip` ;
128
+ }
129
+ else {
130
+ downloadUrl = `${ ORACLE_JDK_BASE_DOWNLOAD_URL } /${ JDKVersion } /latest/jdk-${ JDKVersion } _${ osType . toLowerCase ( ) } -${ osArchitecture } _bin.tar.gz` ;
131
+ }
133
132
}
134
133
135
134
// Define the target directory and file name
@@ -293,7 +292,7 @@ const installationCompletion = async (installType: string) => {
293
292
}
294
293
}
295
294
296
- export const fetchJDKDownloadView = ( machineArch : string , osType : string , versions : any ) : string => {
295
+ export const fetchJDKDownloadView = ( machineArch : string , osType : string , versions : Array < String > ) : string => {
297
296
return `<!DOCTYPE html>
298
297
<head>
299
298
<title>JDK Downloader</title>
@@ -420,7 +419,7 @@ export const fetchJDKDownloadView = (machineArch: string, osType: string, versio
420
419
<br />
421
420
<div class="jdk-version-dropdown">
422
421
<select id="oracleJDKVersionDropdown">
423
- ${ Object . keys ( versions . oracleJdk ) . sort ( ( a , b ) => parseFloat ( b ) - parseFloat ( a ) ) . map ( ( el , index ) => {
422
+ ${ versions . map ( ( el , index ) => {
424
423
if ( index === 0 ) {
425
424
return `<option value=${ el } default>JDK ${ el } </option>`
426
425
}
@@ -460,7 +459,7 @@ export const fetchJDKDownloadView = (machineArch: string, osType: string, versio
460
459
<br />
461
460
<div class="jdk-version-dropdown">
462
461
<select id="openJDKVersionDropdown">
463
- ${ Object . keys ( versions . openJdk ) . sort ( ( a , b ) => parseFloat ( b ) - parseFloat ( a ) ) . map ( ( el , index ) => {
462
+ ${ Object . keys ( OPEN_JDK_VERSION_DOWNLOAD_LINKS ) . map ( ( el , index ) => {
464
463
if ( index === 0 ) {
465
464
return `<option value=${ el } default>JDK ${ el } </option>`
466
465
}
0 commit comments