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);
|
mockJavaBase = new EmptyJavaBase(input);
|
||||||
await expect(mockJavaBase.setupJava()).resolves.toEqual(expected);
|
await expect(mockJavaBase.setupJava()).resolves.toEqual(expected);
|
||||||
expect(spyGetToolcachePath).toHaveBeenCalled();
|
expect(spyGetToolcachePath).toHaveBeenCalled();
|
||||||
expect(spyCoreInfo).toHaveBeenCalledWith(
|
expect(spyCoreInfo).toHaveBeenCalledWith('Trying to resolve latest version remotely');
|
||||||
`Java ${input.version} was not found in tool-cache. Trying to download...`
|
expect(spyCoreInfo).toHaveBeenCalledWith('Trying to download...');
|
||||||
);
|
|
||||||
expect(spyCoreInfo).toHaveBeenCalledWith(`Java ${installedJavaVersion} was downloaded`);
|
expect(spyCoreInfo).toHaveBeenCalledWith(`Java ${installedJavaVersion} was downloaded`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
{ version: '11', architecture: 'x86', packageType: 'jre' },
|
{ 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' },
|
{ 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' },
|
{ 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) => {
|
])('download java with configuration %s', async (input, expected) => {
|
||||||
mockJavaBase = new EmptyJavaBase(input);
|
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);
|
const util_1 = __webpack_require__(322);
|
||||||
class JavaBase {
|
class JavaBase {
|
||||||
constructor(distribution, installerOptions) {
|
constructor(distribution, installerOptions) {
|
||||||
|
var _a;
|
||||||
this.distribution = distribution;
|
this.distribution = distribution;
|
||||||
this.http = new httpm.HttpClient('actions/setup-java', undefined, {
|
this.http = new httpm.HttpClient('actions/setup-java', undefined, {
|
||||||
allowRetries: true,
|
allowRetries: true,
|
||||||
|
@ -3965,7 +3966,7 @@ class JavaBase {
|
||||||
({ version: this.version, stable: this.stable } = this.normalizeVersion(installerOptions.version));
|
({ version: this.version, stable: this.stable } = this.normalizeVersion(installerOptions.version));
|
||||||
this.architecture = installerOptions.architecture;
|
this.architecture = installerOptions.architecture;
|
||||||
this.packageType = installerOptions.packageType;
|
this.packageType = installerOptions.packageType;
|
||||||
this.checkLatest = !!installerOptions.checkLatest;
|
this.checkLatest = (_a = installerOptions.checkLatest) !== null && _a !== void 0 ? _a : false;
|
||||||
}
|
}
|
||||||
setupJava() {
|
setupJava() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
@ -3974,12 +3975,16 @@ class JavaBase {
|
||||||
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
const javaRelease = yield this.findPackageForDownload(this.version);
|
||||||
|
core.info('Trying to download...');
|
||||||
if ((foundJava === null || foundJava === void 0 ? void 0 : foundJava.version) != javaRelease.version) {
|
if ((foundJava === null || foundJava === void 0 ? void 0 : foundJava.version) != javaRelease.version) {
|
||||||
foundJava = yield this.downloadTool(javaRelease);
|
foundJava = yield this.downloadTool(javaRelease);
|
||||||
core.info(`Java ${foundJava.version} was downloaded`);
|
core.info(`Java ${foundJava.version} was downloaded`);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
core.info('latest version was resolved locally');
|
||||||
|
}
|
||||||
core.info(`Java ${foundJava.version} was resolved`);
|
core.info(`Java ${foundJava.version} was resolved`);
|
||||||
}
|
}
|
||||||
core.info(`Setting Java ${foundJava.version} as the default`);
|
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 });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(__webpack_require__(470));
|
const core = __importStar(__webpack_require__(470));
|
||||||
const auth = __importStar(__webpack_require__(331));
|
const auth = __importStar(__webpack_require__(331));
|
||||||
|
const util_1 = __webpack_require__(322);
|
||||||
const constants = __importStar(__webpack_require__(211));
|
const constants = __importStar(__webpack_require__(211));
|
||||||
const path = __importStar(__webpack_require__(622));
|
const path = __importStar(__webpack_require__(622));
|
||||||
const distribution_factory_1 = __webpack_require__(24);
|
const distribution_factory_1 = __webpack_require__(24);
|
||||||
|
@ -35659,12 +35665,12 @@ function run() {
|
||||||
const architecture = core.getInput(constants.INPUT_ARCHITECTURE);
|
const architecture = core.getInput(constants.INPUT_ARCHITECTURE);
|
||||||
const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
|
const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
|
||||||
const jdkFile = core.getInput(constants.INPUT_JDK_FILE);
|
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 = {
|
const installerOptions = {
|
||||||
architecture,
|
architecture,
|
||||||
packageType,
|
packageType,
|
||||||
version,
|
version,
|
||||||
checkLatest: checkLatest ? false : checkLatest.toLowerCase() === 'true'
|
checkLatest
|
||||||
};
|
};
|
||||||
const distribution = distribution_factory_1.getJavaDistribution(distributionName, installerOptions, jdkFile);
|
const distribution = distribution_factory_1.getJavaDistribution(distributionName, installerOptions, jdkFile);
|
||||||
if (!distribution) {
|
if (!distribution) {
|
||||||
|
|
|
@ -25,7 +25,7 @@ export abstract class JavaBase {
|
||||||
));
|
));
|
||||||
this.architecture = installerOptions.architecture;
|
this.architecture = installerOptions.architecture;
|
||||||
this.packageType = installerOptions.packageType;
|
this.packageType = installerOptions.packageType;
|
||||||
this.checkLatest = !!installerOptions.checkLatest;
|
this.checkLatest = installerOptions.checkLatest ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract downloadTool(javaRelease: JavaDownloadRelease): Promise<JavaInstallerResults>;
|
protected abstract downloadTool(javaRelease: JavaDownloadRelease): Promise<JavaInstallerResults>;
|
||||||
|
@ -36,11 +36,14 @@ export abstract class JavaBase {
|
||||||
if (foundJava && !this.checkLatest) {
|
if (foundJava && !this.checkLatest) {
|
||||||
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
||||||
} else {
|
} 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);
|
const javaRelease = await this.findPackageForDownload(this.version);
|
||||||
|
core.info('Trying to download...');
|
||||||
if (foundJava?.version != javaRelease.version) {
|
if (foundJava?.version != javaRelease.version) {
|
||||||
foundJava = await this.downloadTool(javaRelease);
|
foundJava = await this.downloadTool(javaRelease);
|
||||||
core.info(`Java ${foundJava.version} was downloaded`);
|
core.info(`Java ${foundJava.version} was downloaded`);
|
||||||
|
} else {
|
||||||
|
core.info('latest version was resolved locally');
|
||||||
}
|
}
|
||||||
|
|
||||||
core.info(`Java ${foundJava.version} was resolved`);
|
core.info(`Java ${foundJava.version} was resolved`);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as auth from './auth';
|
import * as auth from './auth';
|
||||||
|
import { getBooleanInput } from './util';
|
||||||
import * as constants from './constants';
|
import * as constants from './constants';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { getJavaDistribution } from './distributions/distribution-factory';
|
import { getJavaDistribution } from './distributions/distribution-factory';
|
||||||
|
@ -13,13 +13,13 @@ async function run() {
|
||||||
const architecture = core.getInput(constants.INPUT_ARCHITECTURE);
|
const architecture = core.getInput(constants.INPUT_ARCHITECTURE);
|
||||||
const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
|
const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
|
||||||
const jdkFile = core.getInput(constants.INPUT_JDK_FILE);
|
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 = {
|
const installerOptions: JavaInstallerOptions = {
|
||||||
architecture,
|
architecture,
|
||||||
packageType,
|
packageType,
|
||||||
version,
|
version,
|
||||||
checkLatest: checkLatest ? false : checkLatest.toLowerCase() === 'true'
|
checkLatest
|
||||||
};
|
};
|
||||||
|
|
||||||
const distribution = getJavaDistribution(distributionName, installerOptions, jdkFile);
|
const distribution = getJavaDistribution(distributionName, installerOptions, jdkFile);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue