Fix extracting Java from archive

This commit is contained in:
Daniil Razorenov 2021-11-10 11:47:08 +03:00
parent 1eb0ec886a
commit 221194fabc
2 changed files with 5 additions and 3 deletions

3
dist/setup/index.js vendored
View file

@ -38607,7 +38607,8 @@ class LibericaDistributions extends base_installer_1.JavaBase {
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
const javaArchivePath = yield tc.downloadTool(javaRelease.url); const javaArchivePath = yield tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extractedJavaPath = yield util_1.extractJdkFile(javaArchivePath); const extension = util_1.getDownloadArchiveExtension();
const extractedJavaPath = yield util_1.extractJdkFile(javaArchivePath, extension);
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
const archivePath = path_1.default.join(extractedJavaPath, archiveName); const archivePath = path_1.default.join(extractedJavaPath, archiveName);
const javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaRelease.version), this.architecture); const javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaRelease.version), this.architecture);

View file

@ -1,7 +1,7 @@
import { JavaBase } from '../base-installer'; import { JavaBase } from '../base-installer';
import { JavaDownloadRelease, JavaInstallerOptions, JavaInstallerResults } from '../base-models'; import { JavaDownloadRelease, JavaInstallerOptions, JavaInstallerResults } from '../base-models';
import semver from 'semver'; import semver from 'semver';
import { extractJdkFile, isVersionSatisfies } from '../../util'; import { extractJdkFile, getDownloadArchiveExtension, isVersionSatisfies } from '../../util';
import * as core from '@actions/core'; import * as core from '@actions/core';
import { ArchitectureOptions, LibericaVersion, OsVersions } from './models'; import { ArchitectureOptions, LibericaVersion, OsVersions } from './models';
import * as tc from '@actions/tool-cache'; import * as tc from '@actions/tool-cache';
@ -24,7 +24,8 @@ export class LibericaDistributions extends JavaBase {
const javaArchivePath = await tc.downloadTool(javaRelease.url); const javaArchivePath = await tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extractedJavaPath = await extractJdkFile(javaArchivePath); const extension = getDownloadArchiveExtension();
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
const archiveName = fs.readdirSync(extractedJavaPath)[0]; const archiveName = fs.readdirSync(extractedJavaPath)[0];
const archivePath = path.join(extractedJavaPath, archiveName); const archivePath = path.join(extractedJavaPath, archiveName);