mirror of
https://github.com/actions/setup-java.git
synced 2025-04-20 18:06:45 +00:00
resolving comments
This commit is contained in:
parent
b59200979a
commit
9887b5cf97
4 changed files with 23 additions and 15 deletions
|
@ -225,24 +225,23 @@ describe('setupJava', () => {
|
|||
mockJavaBase = new EmptyJavaBase(input);
|
||||
await expect(mockJavaBase.setupJava()).resolves.toEqual(expected);
|
||||
expect(spyGetToolcachePath).toHaveBeenCalled();
|
||||
expect(spyCoreInfo).toHaveBeenCalledWith(
|
||||
`Java ${input.version} was not found in tool-cache. Trying to download...`
|
||||
);
|
||||
expect(spyCoreInfo).toHaveBeenCalledWith('Trying to resolve latest version remotely');
|
||||
expect(spyCoreInfo).toHaveBeenCalledWith('Trying to download...');
|
||||
expect(spyCoreInfo).toHaveBeenCalledWith(`Java ${installedJavaVersion} was downloaded`);
|
||||
});
|
||||
|
||||
it.each([
|
||||
[
|
||||
{ version: '11', architecture: 'x86', packageType: 'jre' },
|
||||
{ path: `toolcache/Java_Empty_jre/11.0.9/x86`, version: '11.0.9' }
|
||||
{ path: path.join('toolcache', 'Java_Empty_jre', '11.0.9', 'x86'), version: '11.0.9' }
|
||||
],
|
||||
[
|
||||
{ version: '11', architecture: 'x64', packageType: 'jdk' },
|
||||
{ path: `toolcache/Java_Empty_jdk/11.0.9/x64`, version: '11.0.9' }
|
||||
{ path: path.join('toolcache', 'Java_Empty_jdk', '11.0.9', 'x64'), version: '11.0.9' }
|
||||
],
|
||||
[
|
||||
{ version: '11', architecture: 'x64', packageType: 'jre' },
|
||||
{ path: `toolcache/Java_Empty_jre/11.0.9/x64`, version: '11.0.9' }
|
||||
{ path: path.join('toolcache', 'Java_Empty_jre', '11.0.9', 'x64'), version: '11.0.9' }
|
||||
]
|
||||
])('download java with configuration %s', async (input, expected) => {
|
||||
mockJavaBase = new EmptyJavaBase(input);
|
||||
|
|
14
dist/setup/index.js
vendored
14
dist/setup/index.js
vendored
|
@ -3957,6 +3957,7 @@ const httpm = __importStar(__webpack_require__(539));
|
|||
const util_1 = __webpack_require__(322);
|
||||
class JavaBase {
|
||||
constructor(distribution, installerOptions) {
|
||||
var _a;
|
||||
this.distribution = distribution;
|
||||
this.http = new httpm.HttpClient('actions/setup-java', undefined, {
|
||||
allowRetries: true,
|
||||
|
@ -3965,7 +3966,7 @@ class JavaBase {
|
|||
({ version: this.version, stable: this.stable } = this.normalizeVersion(installerOptions.version));
|
||||
this.architecture = installerOptions.architecture;
|
||||
this.packageType = installerOptions.packageType;
|
||||
this.checkLatest = !!installerOptions.checkLatest;
|
||||
this.checkLatest = (_a = installerOptions.checkLatest) !== null && _a !== void 0 ? _a : false;
|
||||
}
|
||||
setupJava() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
|
@ -3974,12 +3975,16 @@ class JavaBase {
|
|||
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
||||
}
|
||||
else {
|
||||
core.info(`Java ${this.version} was not found in tool-cache. Trying to download...`);
|
||||
core.info('Trying to resolve latest version remotely');
|
||||
const javaRelease = yield this.findPackageForDownload(this.version);
|
||||
core.info('Trying to download...');
|
||||
if ((foundJava === null || foundJava === void 0 ? void 0 : foundJava.version) != javaRelease.version) {
|
||||
foundJava = yield this.downloadTool(javaRelease);
|
||||
core.info(`Java ${foundJava.version} was downloaded`);
|
||||
}
|
||||
else {
|
||||
core.info('latest version was resolved locally');
|
||||
}
|
||||
core.info(`Java ${foundJava.version} was resolved`);
|
||||
}
|
||||
core.info(`Setting Java ${foundJava.version} as the default`);
|
||||
|
@ -35648,6 +35653,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(__webpack_require__(470));
|
||||
const auth = __importStar(__webpack_require__(331));
|
||||
const util_1 = __webpack_require__(322);
|
||||
const constants = __importStar(__webpack_require__(211));
|
||||
const path = __importStar(__webpack_require__(622));
|
||||
const distribution_factory_1 = __webpack_require__(24);
|
||||
|
@ -35659,12 +35665,12 @@ function run() {
|
|||
const architecture = core.getInput(constants.INPUT_ARCHITECTURE);
|
||||
const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
|
||||
const jdkFile = core.getInput(constants.INPUT_JDK_FILE);
|
||||
const checkLatest = core.getInput(constants.INPUT_CHECK_LATEST);
|
||||
const checkLatest = util_1.getBooleanInput(constants.INPUT_CHECK_LATEST, false);
|
||||
const installerOptions = {
|
||||
architecture,
|
||||
packageType,
|
||||
version,
|
||||
checkLatest: checkLatest ? false : checkLatest.toLowerCase() === 'true'
|
||||
checkLatest
|
||||
};
|
||||
const distribution = distribution_factory_1.getJavaDistribution(distributionName, installerOptions, jdkFile);
|
||||
if (!distribution) {
|
||||
|
|
|
@ -25,7 +25,7 @@ export abstract class JavaBase {
|
|||
));
|
||||
this.architecture = installerOptions.architecture;
|
||||
this.packageType = installerOptions.packageType;
|
||||
this.checkLatest = !!installerOptions.checkLatest;
|
||||
this.checkLatest = installerOptions.checkLatest ?? false;
|
||||
}
|
||||
|
||||
protected abstract downloadTool(javaRelease: JavaDownloadRelease): Promise<JavaInstallerResults>;
|
||||
|
@ -36,11 +36,14 @@ export abstract class JavaBase {
|
|||
if (foundJava && !this.checkLatest) {
|
||||
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
||||
} else {
|
||||
core.info(`Java ${this.version} was not found in tool-cache. Trying to download...`);
|
||||
core.info('Trying to resolve latest version remotely');
|
||||
const javaRelease = await this.findPackageForDownload(this.version);
|
||||
core.info('Trying to download...');
|
||||
if (foundJava?.version != javaRelease.version) {
|
||||
foundJava = await this.downloadTool(javaRelease);
|
||||
core.info(`Java ${foundJava.version} was downloaded`);
|
||||
} else {
|
||||
core.info('latest version was resolved locally');
|
||||
}
|
||||
|
||||
core.info(`Java ${foundJava.version} was resolved`);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as core from '@actions/core';
|
||||
import * as auth from './auth';
|
||||
|
||||
import { getBooleanInput } from './util';
|
||||
import * as constants from './constants';
|
||||
import * as path from 'path';
|
||||
import { getJavaDistribution } from './distributions/distribution-factory';
|
||||
|
@ -13,13 +13,13 @@ async function run() {
|
|||
const architecture = core.getInput(constants.INPUT_ARCHITECTURE);
|
||||
const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
|
||||
const jdkFile = core.getInput(constants.INPUT_JDK_FILE);
|
||||
const checkLatest = core.getInput(constants.INPUT_CHECK_LATEST);
|
||||
const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false);
|
||||
|
||||
const installerOptions: JavaInstallerOptions = {
|
||||
architecture,
|
||||
packageType,
|
||||
version,
|
||||
checkLatest: checkLatest ? false : checkLatest.toLowerCase() === 'true'
|
||||
checkLatest
|
||||
};
|
||||
|
||||
const distribution = getJavaDistribution(distributionName, installerOptions, jdkFile);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue