From b1be936638e359a6eb881cfe4c4e3f619c1dbf3c Mon Sep 17 00:00:00 2001 From: Nikita Ezzhev Date: Thu, 13 May 2021 13:54:03 +0300 Subject: [PATCH 1/9] Add option to not create directory for jdk unpacking --- Tasks/JavaToolInstallerV0/javatoolinstaller.ts | 11 +++++++++-- Tasks/JavaToolInstallerV0/task.json | 13 +++++++++++-- Tasks/JavaToolInstallerV0/task.loc.json | 4 ++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Tasks/JavaToolInstallerV0/javatoolinstaller.ts b/Tasks/JavaToolInstallerV0/javatoolinstaller.ts index c1900d574054..8ca3fc604a7e 100644 --- a/Tasks/JavaToolInstallerV0/javatoolinstaller.ts +++ b/Tasks/JavaToolInstallerV0/javatoolinstaller.ts @@ -128,9 +128,16 @@ async function installJDK(sourceFile: string, fileExtension: string, archiveExtr jdkDirectory = await installPkg(sourceFile, extendedJavaHome, versionSpec); } else { + const createExtractDirectory: boolean = taskLib.getBoolInput('cleanDestinationDirectory', false); + let extractionDirectory: string = ""; + + if (createExtractDirectory){ + const extractDirectoryName: string = `${extendedJavaHome}_${JavaFilesExtractor.getStrippedName(sourceFile)}_${fileExtension.substr(1)}`; + extractionDirectory = path.join(archiveExtractLocation, extractDirectoryName); + } else { + extractionDirectory = path.join(archiveExtractLocation); + } // unpack the archive, set `JAVA_HOME` and save it for further processing - const extractDirectoryName: string = `${extendedJavaHome}_${JavaFilesExtractor.getStrippedName(sourceFile)}_${fileExtension.substr(1)}`; - const extractionDirectory: string = path.join(archiveExtractLocation, extractDirectoryName); await unpackArchive(extractionDirectory, sourceFile, fileExtension, cleanDestinationDirectory); jdkDirectory = JavaFilesExtractor.setJavaHome(extractionDirectory); } diff --git a/Tasks/JavaToolInstallerV0/task.json b/Tasks/JavaToolInstallerV0/task.json index ed63b0d0aedd..370a353a0821 100644 --- a/Tasks/JavaToolInstallerV0/task.json +++ b/Tasks/JavaToolInstallerV0/task.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 0, - "Minor": 186, - "Patch": 1 + "Minor": 188, + "Patch": 0 }, "satisfies": [ "Java", @@ -126,6 +126,15 @@ "visibleRule": "jdkSourceOption != PreInstalled", "helpMarkDown": "Select this option to clean the destination directory before JDK is extracted into it." } + { + "name": "createExtractDirectory", + "type": "boolean", + "label": "Create directory for extracting", + "required": false, + "defaultValue": true, + "visibleRule": "jdkSourceOption != PreInstalled", + "helpMarkDown": "By default taks is creating directory similar to this JAVA_HOME_8_X64_OpenJDK_zip for extracting JDK. This option allow to disable ctreation of this folder, in this case JDK will be located in root of jdkDestinationDirectory" + } ], "dataSourceBindings": [ { diff --git a/Tasks/JavaToolInstallerV0/task.loc.json b/Tasks/JavaToolInstallerV0/task.loc.json index 8d7ce2038115..ca9f45463412 100644 --- a/Tasks/JavaToolInstallerV0/task.loc.json +++ b/Tasks/JavaToolInstallerV0/task.loc.json @@ -13,8 +13,8 @@ "author": "Microsoft Corporation", "version": { "Major": 0, - "Minor": 186, - "Patch": 1 + "Minor": 188, + "Patch": 0 }, "satisfies": [ "Java", From cc7a52712428d31c625afecb088b3e535b1a96b0 Mon Sep 17 00:00:00 2001 From: Nikita Ezzhev Date: Thu, 13 May 2021 13:59:57 +0300 Subject: [PATCH 2/9] Regenerated task.loc.json and resjson --- .../Strings/resources.resjson/en-US/resources.resjson | 4 +++- Tasks/JavaToolInstallerV0/task.json | 2 +- Tasks/JavaToolInstallerV0/task.loc.json | 9 +++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Tasks/JavaToolInstallerV0/Strings/resources.resjson/en-US/resources.resjson b/Tasks/JavaToolInstallerV0/Strings/resources.resjson/en-US/resources.resjson index 6dc2f88a1535..a73e36bacd1c 100644 --- a/Tasks/JavaToolInstallerV0/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/JavaToolInstallerV0/Strings/resources.resjson/en-US/resources.resjson @@ -21,9 +21,11 @@ "loc.input.label.azureCommonVirtualFile": "Common virtual path", "loc.input.help.azureCommonVirtualFile": "Path to the JDK inside the Azure storage container.", "loc.input.label.jdkDestinationDirectory": "Destination directory", - "loc.input.help.jdkDestinationDirectory": "On Linux and Windows, this is used as the destination directory for JDK installation. On macOS, this directory is used as a temporary folder for extracting .dmg's since macOS doesn't support installing of JDK to specific directory.", + "loc.input.help.jdkDestinationDirectory": "On Linux and Windows, this is used as the destination directory for JDK installation. On macOS, this directory is used as a temporary folder for extracting of .dmg's since macOS doesn't support installing of JDK to specific directory.", "loc.input.label.cleanDestinationDirectory": "Clean destination directory", "loc.input.help.cleanDestinationDirectory": "Select this option to clean the destination directory before JDK is extracted into it.", + "loc.input.label.createExtractDirectory": "Create directory for extracting", + "loc.input.help.createExtractDirectory": "By default taks is creating directory similar to this JAVA_HOME_8_X64_OpenJDK_zip for extracting JDK. This option allow to disable ctreation of this folder, in this case JDK will be located in root of jdkDestinationDirectory", "loc.messages.DownloadFromAzureBlobStorage": "Downloading artifacts from Azure blob storage, Container Name: %s", "loc.messages.SuccessFullyFetchedItemList": "Successfully fetched list of items", "loc.messages.StorageAccountDoesNotExist": "Failed to get azure storage account with name %s.", diff --git a/Tasks/JavaToolInstallerV0/task.json b/Tasks/JavaToolInstallerV0/task.json index 370a353a0821..39941e486805 100644 --- a/Tasks/JavaToolInstallerV0/task.json +++ b/Tasks/JavaToolInstallerV0/task.json @@ -125,7 +125,7 @@ "defaultValue": "true", "visibleRule": "jdkSourceOption != PreInstalled", "helpMarkDown": "Select this option to clean the destination directory before JDK is extracted into it." - } + }, { "name": "createExtractDirectory", "type": "boolean", diff --git a/Tasks/JavaToolInstallerV0/task.loc.json b/Tasks/JavaToolInstallerV0/task.loc.json index ca9f45463412..7e4edbd002e4 100644 --- a/Tasks/JavaToolInstallerV0/task.loc.json +++ b/Tasks/JavaToolInstallerV0/task.loc.json @@ -125,6 +125,15 @@ "defaultValue": "true", "visibleRule": "jdkSourceOption != PreInstalled", "helpMarkDown": "ms-resource:loc.input.help.cleanDestinationDirectory" + }, + { + "name": "createExtractDirectory", + "type": "boolean", + "label": "ms-resource:loc.input.label.createExtractDirectory", + "required": false, + "defaultValue": true, + "visibleRule": "jdkSourceOption != PreInstalled", + "helpMarkDown": "ms-resource:loc.input.help.createExtractDirectory" } ], "dataSourceBindings": [ From 2c8c70baf9b60a269fb319259c8f71355f065a1b Mon Sep 17 00:00:00 2001 From: Nikita Ezzhev Date: Fri, 14 May 2021 10:06:28 +0300 Subject: [PATCH 3/9] Added test --- .../FileExtractor/JavaFilesExtractor.ts | 2 ++ Tasks/JavaToolInstallerV0/Tests/L0.ts | 24 +++++++++++++++++++ .../JavaToolInstallerV0/Tests/L0UnzipTest.ts | 1 + .../JavaToolInstallerV0/javatoolinstaller.ts | 6 ++++- 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Tasks/JavaToolInstallerV0/FileExtractor/JavaFilesExtractor.ts b/Tasks/JavaToolInstallerV0/FileExtractor/JavaFilesExtractor.ts index d68841979c6a..16a192805c5a 100644 --- a/Tasks/JavaToolInstallerV0/FileExtractor/JavaFilesExtractor.ts +++ b/Tasks/JavaToolInstallerV0/FileExtractor/JavaFilesExtractor.ts @@ -216,7 +216,9 @@ export class JavaFilesExtractor { JavaFilesExtractor.getJavaHomeFromStructure(pathToExtractedJDK) : pathToExtractedJDK; console.log(taskLib.loc('SetJavaHome', jdkDirectory)); + console.log('------------WE_ARE_HERE_PART_2------------'); taskLib.setVariable('JAVA_HOME', jdkDirectory); + console.log('------------WE_ARE_HERE_PART_3------------'); return jdkDirectory; } diff --git a/Tasks/JavaToolInstallerV0/Tests/L0.ts b/Tasks/JavaToolInstallerV0/Tests/L0.ts index 8d6e7be6a061..f48d50b843a2 100644 --- a/Tasks/JavaToolInstallerV0/Tests/L0.ts +++ b/Tasks/JavaToolInstallerV0/Tests/L0.ts @@ -39,4 +39,28 @@ describe('JavaToolInstaller L0 Suite', function () { assert(testRunner.failed, 'task should have failed'); }); + + // it('should fail when JavaToolInstaller is run with to destination folder specified', function () { + // this.timeout(20000); + + // const testPath: string = path.join(__dirname, 'L0UnzipTest.js'); + // const testRunner: ttm.MockTestRunner = new ttm.MockTestRunner(testPath); + + // testRunner.run(); + // console.log(testRunner.stdout); + + // assert(testRunner.succeeded, 'task should have succeeded.'); + // }); + + it('should not fail', function () { + this.timeout(20000); + + const testPath: string = path.join(__dirname, 'L0CheckExtractDirectory.js'); + const testRunner: ttm.MockTestRunner = new ttm.MockTestRunner(testPath); + + testRunner.run(); + console.log(testRunner.stdout); + + assert(testRunner.succeeded, 'task should have succeeded.'); + }); }); diff --git a/Tasks/JavaToolInstallerV0/Tests/L0UnzipTest.ts b/Tasks/JavaToolInstallerV0/Tests/L0UnzipTest.ts index 378ef197c321..13559e25379d 100644 --- a/Tasks/JavaToolInstallerV0/Tests/L0UnzipTest.ts +++ b/Tasks/JavaToolInstallerV0/Tests/L0UnzipTest.ts @@ -19,6 +19,7 @@ tr.setInput("jdkArchitectureOption", "x64"); // set windir process.env.windir = 'windir'; +process.env['TOOLDIRECTORY'] = 'toolsdirectory'; // provide answers for task mock const a: mockanswer.TaskLibAnswers = { diff --git a/Tasks/JavaToolInstallerV0/javatoolinstaller.ts b/Tasks/JavaToolInstallerV0/javatoolinstaller.ts index 8ca3fc604a7e..629f42a906a3 100644 --- a/Tasks/JavaToolInstallerV0/javatoolinstaller.ts +++ b/Tasks/JavaToolInstallerV0/javatoolinstaller.ts @@ -71,9 +71,13 @@ async function getJava(versionSpec: string, jdkArchitectureOption: string): Prom compressedFileExtension = JavaFilesExtractor.getSupportedFileEnding(jdkFileName); jdkDirectory = await installJDK(jdkFileName, compressedFileExtension, extractLocation, extendedJavaHome, versionSpec, cleanDestinationDirectory); } + console.log('------------WE_ARE_HERE_PART_4------------'); console.log(taskLib.loc('SetExtendedJavaHome', extendedJavaHome, jdkDirectory)); + console.log('------------WE_ARE_HERE_PART_5------------'); taskLib.setVariable(extendedJavaHome, jdkDirectory); + console.log('------------WE_ARE_HERE_PART_6------------'); toolLib.prependPath(path.join(jdkDirectory, BIN_FOLDER)); + console.log('------------WE_ARE_HERE_PART_7------------'); } /** @@ -130,7 +134,7 @@ async function installJDK(sourceFile: string, fileExtension: string, archiveExtr else { const createExtractDirectory: boolean = taskLib.getBoolInput('cleanDestinationDirectory', false); let extractionDirectory: string = ""; - + console.log("----------------We are here----------------: " + jdkDirectory); if (createExtractDirectory){ const extractDirectoryName: string = `${extendedJavaHome}_${JavaFilesExtractor.getStrippedName(sourceFile)}_${fileExtension.substr(1)}`; extractionDirectory = path.join(archiveExtractLocation, extractDirectoryName); From e9f3a633c6c8c470a275a717a781502e73397716 Mon Sep 17 00:00:00 2001 From: Nikita Ezzhev Date: Mon, 17 May 2021 08:59:33 +0300 Subject: [PATCH 4/9] Reverted extra change --- Tasks/JavaToolInstallerV0/task.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/JavaToolInstallerV0/task.json b/Tasks/JavaToolInstallerV0/task.json index 39941e486805..06f4135d153c 100644 --- a/Tasks/JavaToolInstallerV0/task.json +++ b/Tasks/JavaToolInstallerV0/task.json @@ -115,7 +115,7 @@ "defaultValue": "", "required": true, "visibleRule": "jdkSourceOption != PreInstalled", - "helpMarkDown": "On Linux and Windows, this is used as the destination directory for JDK installation. On macOS, this directory is used as a temporary folder for extracting of .dmg's since macOS doesn't support installing of JDK to specific directory." + "helpMarkDown": "On Linux and Windows, this is used as the destination directory for JDK installation. On macOS, this directory is used as a temporary folder for extracting .dmg's since macOS doesn't support installing of JDK to specific directory." }, { "name": "cleanDestinationDirectory", From 47363e6273aedacce6eb86fd07df3f60f640e7f0 Mon Sep 17 00:00:00 2001 From: Nikita Ezzhev Date: Mon, 17 May 2021 09:06:06 +0300 Subject: [PATCH 5/9] Reverted extra changes --- .../FileExtractor/JavaFilesExtractor.ts | 2 -- .../resources.resjson/en-US/resources.resjson | 2 +- Tasks/JavaToolInstallerV0/Tests/L0.ts | 24 ------------------- .../JavaToolInstallerV0/Tests/L0UnzipTest.ts | 1 - .../JavaToolInstallerV0/javatoolinstaller.ts | 5 ---- Tasks/JavaToolInstallerV0/task.json | 4 ++-- 6 files changed, 3 insertions(+), 35 deletions(-) diff --git a/Tasks/JavaToolInstallerV0/FileExtractor/JavaFilesExtractor.ts b/Tasks/JavaToolInstallerV0/FileExtractor/JavaFilesExtractor.ts index 16a192805c5a..d68841979c6a 100644 --- a/Tasks/JavaToolInstallerV0/FileExtractor/JavaFilesExtractor.ts +++ b/Tasks/JavaToolInstallerV0/FileExtractor/JavaFilesExtractor.ts @@ -216,9 +216,7 @@ export class JavaFilesExtractor { JavaFilesExtractor.getJavaHomeFromStructure(pathToExtractedJDK) : pathToExtractedJDK; console.log(taskLib.loc('SetJavaHome', jdkDirectory)); - console.log('------------WE_ARE_HERE_PART_2------------'); taskLib.setVariable('JAVA_HOME', jdkDirectory); - console.log('------------WE_ARE_HERE_PART_3------------'); return jdkDirectory; } diff --git a/Tasks/JavaToolInstallerV0/Strings/resources.resjson/en-US/resources.resjson b/Tasks/JavaToolInstallerV0/Strings/resources.resjson/en-US/resources.resjson index a73e36bacd1c..f03a34183ed4 100644 --- a/Tasks/JavaToolInstallerV0/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/JavaToolInstallerV0/Strings/resources.resjson/en-US/resources.resjson @@ -25,7 +25,7 @@ "loc.input.label.cleanDestinationDirectory": "Clean destination directory", "loc.input.help.cleanDestinationDirectory": "Select this option to clean the destination directory before JDK is extracted into it.", "loc.input.label.createExtractDirectory": "Create directory for extracting", - "loc.input.help.createExtractDirectory": "By default taks is creating directory similar to this JAVA_HOME_8_X64_OpenJDK_zip for extracting JDK. This option allow to disable ctreation of this folder, in this case JDK will be located in root of jdkDestinationDirectory", + "loc.input.help.createExtractDirectory": "By default, task is creating a directory similar to this JAVA_HOME_8_X64_OpenJDK_zip for extracting JDK. This option allows to disable creation of this folder, in this case, JDK will be located in the root of jdkDestinationDirectory", "loc.messages.DownloadFromAzureBlobStorage": "Downloading artifacts from Azure blob storage, Container Name: %s", "loc.messages.SuccessFullyFetchedItemList": "Successfully fetched list of items", "loc.messages.StorageAccountDoesNotExist": "Failed to get azure storage account with name %s.", diff --git a/Tasks/JavaToolInstallerV0/Tests/L0.ts b/Tasks/JavaToolInstallerV0/Tests/L0.ts index f48d50b843a2..8d6e7be6a061 100644 --- a/Tasks/JavaToolInstallerV0/Tests/L0.ts +++ b/Tasks/JavaToolInstallerV0/Tests/L0.ts @@ -39,28 +39,4 @@ describe('JavaToolInstaller L0 Suite', function () { assert(testRunner.failed, 'task should have failed'); }); - - // it('should fail when JavaToolInstaller is run with to destination folder specified', function () { - // this.timeout(20000); - - // const testPath: string = path.join(__dirname, 'L0UnzipTest.js'); - // const testRunner: ttm.MockTestRunner = new ttm.MockTestRunner(testPath); - - // testRunner.run(); - // console.log(testRunner.stdout); - - // assert(testRunner.succeeded, 'task should have succeeded.'); - // }); - - it('should not fail', function () { - this.timeout(20000); - - const testPath: string = path.join(__dirname, 'L0CheckExtractDirectory.js'); - const testRunner: ttm.MockTestRunner = new ttm.MockTestRunner(testPath); - - testRunner.run(); - console.log(testRunner.stdout); - - assert(testRunner.succeeded, 'task should have succeeded.'); - }); }); diff --git a/Tasks/JavaToolInstallerV0/Tests/L0UnzipTest.ts b/Tasks/JavaToolInstallerV0/Tests/L0UnzipTest.ts index 13559e25379d..378ef197c321 100644 --- a/Tasks/JavaToolInstallerV0/Tests/L0UnzipTest.ts +++ b/Tasks/JavaToolInstallerV0/Tests/L0UnzipTest.ts @@ -19,7 +19,6 @@ tr.setInput("jdkArchitectureOption", "x64"); // set windir process.env.windir = 'windir'; -process.env['TOOLDIRECTORY'] = 'toolsdirectory'; // provide answers for task mock const a: mockanswer.TaskLibAnswers = { diff --git a/Tasks/JavaToolInstallerV0/javatoolinstaller.ts b/Tasks/JavaToolInstallerV0/javatoolinstaller.ts index 629f42a906a3..4aa45e356834 100644 --- a/Tasks/JavaToolInstallerV0/javatoolinstaller.ts +++ b/Tasks/JavaToolInstallerV0/javatoolinstaller.ts @@ -71,13 +71,9 @@ async function getJava(versionSpec: string, jdkArchitectureOption: string): Prom compressedFileExtension = JavaFilesExtractor.getSupportedFileEnding(jdkFileName); jdkDirectory = await installJDK(jdkFileName, compressedFileExtension, extractLocation, extendedJavaHome, versionSpec, cleanDestinationDirectory); } - console.log('------------WE_ARE_HERE_PART_4------------'); console.log(taskLib.loc('SetExtendedJavaHome', extendedJavaHome, jdkDirectory)); - console.log('------------WE_ARE_HERE_PART_5------------'); taskLib.setVariable(extendedJavaHome, jdkDirectory); - console.log('------------WE_ARE_HERE_PART_6------------'); toolLib.prependPath(path.join(jdkDirectory, BIN_FOLDER)); - console.log('------------WE_ARE_HERE_PART_7------------'); } /** @@ -134,7 +130,6 @@ async function installJDK(sourceFile: string, fileExtension: string, archiveExtr else { const createExtractDirectory: boolean = taskLib.getBoolInput('cleanDestinationDirectory', false); let extractionDirectory: string = ""; - console.log("----------------We are here----------------: " + jdkDirectory); if (createExtractDirectory){ const extractDirectoryName: string = `${extendedJavaHome}_${JavaFilesExtractor.getStrippedName(sourceFile)}_${fileExtension.substr(1)}`; extractionDirectory = path.join(archiveExtractLocation, extractDirectoryName); diff --git a/Tasks/JavaToolInstallerV0/task.json b/Tasks/JavaToolInstallerV0/task.json index 06f4135d153c..b80cd998c5d3 100644 --- a/Tasks/JavaToolInstallerV0/task.json +++ b/Tasks/JavaToolInstallerV0/task.json @@ -115,7 +115,7 @@ "defaultValue": "", "required": true, "visibleRule": "jdkSourceOption != PreInstalled", - "helpMarkDown": "On Linux and Windows, this is used as the destination directory for JDK installation. On macOS, this directory is used as a temporary folder for extracting .dmg's since macOS doesn't support installing of JDK to specific directory." + "helpMarkDown": "On Linux and Windows, this is used as the destination directory for JDK installation. On macOS, this directory is used as a temporary folder for extracting of .dmg's since macOS doesn't support installing of JDK to specific directory." }, { "name": "cleanDestinationDirectory", @@ -133,7 +133,7 @@ "required": false, "defaultValue": true, "visibleRule": "jdkSourceOption != PreInstalled", - "helpMarkDown": "By default taks is creating directory similar to this JAVA_HOME_8_X64_OpenJDK_zip for extracting JDK. This option allow to disable ctreation of this folder, in this case JDK will be located in root of jdkDestinationDirectory" + "helpMarkDown": "By default, task is creating a directory similar to this JAVA_HOME_8_X64_OpenJDK_zip for extracting JDK. This option allows to disable creation of this folder, in this case, JDK will be located in the root of jdkDestinationDirectory" } ], "dataSourceBindings": [ From 3aef54bc66294086f286acbe38035a6ac1dc4961 Mon Sep 17 00:00:00 2001 From: Nikita Ezzhev Date: Mon, 17 May 2021 11:56:34 +0300 Subject: [PATCH 6/9] Address review points --- Tasks/JavaToolInstallerV0/javatoolinstaller.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tasks/JavaToolInstallerV0/javatoolinstaller.ts b/Tasks/JavaToolInstallerV0/javatoolinstaller.ts index 4aa45e356834..91145cb23dad 100644 --- a/Tasks/JavaToolInstallerV0/javatoolinstaller.ts +++ b/Tasks/JavaToolInstallerV0/javatoolinstaller.ts @@ -128,9 +128,9 @@ async function installJDK(sourceFile: string, fileExtension: string, archiveExtr jdkDirectory = await installPkg(sourceFile, extendedJavaHome, versionSpec); } else { - const createExtractDirectory: boolean = taskLib.getBoolInput('cleanDestinationDirectory', false); + const createExtractDirectory: boolean = taskLib.getBoolInput('createExtractDirectory', false); let extractionDirectory: string = ""; - if (createExtractDirectory){ + if (createExtractDirectory) { const extractDirectoryName: string = `${extendedJavaHome}_${JavaFilesExtractor.getStrippedName(sourceFile)}_${fileExtension.substr(1)}`; extractionDirectory = path.join(archiveExtractLocation, extractDirectoryName); } else { From 35046e3b6787166a970fa119c668015cab1faf59 Mon Sep 17 00:00:00 2001 From: Nikita Ezzhev Date: Tue, 18 May 2021 08:37:17 +0300 Subject: [PATCH 7/9] Fix issue with trailing slash in extraction directory --- Tasks/JavaToolInstallerV0/javatoolinstaller.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Tasks/JavaToolInstallerV0/javatoolinstaller.ts b/Tasks/JavaToolInstallerV0/javatoolinstaller.ts index 91145cb23dad..0900e964b869 100644 --- a/Tasks/JavaToolInstallerV0/javatoolinstaller.ts +++ b/Tasks/JavaToolInstallerV0/javatoolinstaller.ts @@ -134,7 +134,12 @@ async function installJDK(sourceFile: string, fileExtension: string, archiveExtr const extractDirectoryName: string = `${extendedJavaHome}_${JavaFilesExtractor.getStrippedName(sourceFile)}_${fileExtension.substr(1)}`; extractionDirectory = path.join(archiveExtractLocation, extractDirectoryName); } else { - extractionDirectory = path.join(archiveExtractLocation); + // we need to remove path separator symbol on the end of archiveExtractLocation path since it could produce issues in getJavaHomeFromStructure method + if (archiveExtractLocation.endsWith(path.sep)) { + archiveExtractLocation = archiveExtractLocation.slice(0, -1); + } + + extractionDirectory = path.normalize(archiveExtractLocation); } // unpack the archive, set `JAVA_HOME` and save it for further processing await unpackArchive(extractionDirectory, sourceFile, fileExtension, cleanDestinationDirectory); From eb6383703e452662279e1392fe9fe1ec19e43e7b Mon Sep 17 00:00:00 2001 From: Nikita Ezzhev Date: Tue, 18 May 2021 16:57:39 +0300 Subject: [PATCH 8/9] Fix issue for jdk installation from azure --- .../FileExtractor/JavaFilesExtractor.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Tasks/JavaToolInstallerV0/FileExtractor/JavaFilesExtractor.ts b/Tasks/JavaToolInstallerV0/FileExtractor/JavaFilesExtractor.ts index d68841979c6a..fb9f8b99f28b 100644 --- a/Tasks/JavaToolInstallerV0/FileExtractor/JavaFilesExtractor.ts +++ b/Tasks/JavaToolInstallerV0/FileExtractor/JavaFilesExtractor.ts @@ -192,11 +192,19 @@ export class JavaFilesExtractor { */ public static getJavaHomeFromStructure(pathToStructure): string { const structure: Array = taskLib.find(pathToStructure); - const rootDirectoriesArray: Array = JavaFilesExtractor.sliceStructure(structure); + const rootItemsArray: Array = JavaFilesExtractor.sliceStructure(structure); + const rootDirectoriesArray: Array = new Array(); + // it is allowed to have extra files in extraction directory, but we shouldn't have more than 1 directory here + rootItemsArray.forEach(rootItem => { + if (fs.lstatSync(path.join(pathToStructure, rootItem)).isDirectory()) { + rootDirectoriesArray.push(rootItem); + } + }); + let jdkDirectory: string; if (rootDirectoriesArray.find(dir => dir === BIN_FOLDER)){ jdkDirectory = pathToStructure; - } else { + } else { jdkDirectory = path.join(pathToStructure, rootDirectoriesArray[0]); const ifBinExistsInside: boolean = fs.existsSync(path.join(jdkDirectory, BIN_FOLDER)); if (rootDirectoriesArray.length > 1 || !ifBinExistsInside){ From 678b84270369817e9b2d5009948124c09e9476de Mon Sep 17 00:00:00 2001 From: Nikita Ezzhev Date: Tue, 18 May 2021 16:59:13 +0300 Subject: [PATCH 9/9] Fix nit --- Tasks/JavaToolInstallerV0/FileExtractor/JavaFilesExtractor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/JavaToolInstallerV0/FileExtractor/JavaFilesExtractor.ts b/Tasks/JavaToolInstallerV0/FileExtractor/JavaFilesExtractor.ts index fb9f8b99f28b..7366eae151c9 100644 --- a/Tasks/JavaToolInstallerV0/FileExtractor/JavaFilesExtractor.ts +++ b/Tasks/JavaToolInstallerV0/FileExtractor/JavaFilesExtractor.ts @@ -204,7 +204,7 @@ export class JavaFilesExtractor { let jdkDirectory: string; if (rootDirectoriesArray.find(dir => dir === BIN_FOLDER)){ jdkDirectory = pathToStructure; - } else { + } else { jdkDirectory = path.join(pathToStructure, rootDirectoriesArray[0]); const ifBinExistsInside: boolean = fs.existsSync(path.join(jdkDirectory, BIN_FOLDER)); if (rootDirectoriesArray.length > 1 || !ifBinExistsInside){