mirror of
https://github.com/actions/setup-java.git
synced 2025-04-20 09:56:46 +00:00
format & build
This commit is contained in:
parent
0143667d3d
commit
f68f88a1bc
4 changed files with 74 additions and 57 deletions
3
dist/cleanup/index.js
vendored
3
dist/cleanup/index.js
vendored
|
@ -68480,7 +68480,7 @@ else {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
|
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
|
||||||
exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
|
exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
|
||||||
exports.INPUT_JAVA_VERSION = 'java-version';
|
exports.INPUT_JAVA_VERSION = 'java-version';
|
||||||
exports.INPUT_JAVA_VERSION_FILE = 'java-version-file';
|
exports.INPUT_JAVA_VERSION_FILE = 'java-version-file';
|
||||||
|
@ -68506,6 +68506,7 @@ exports.MVN_SETTINGS_FILE = 'settings.xml';
|
||||||
exports.MVN_TOOLCHAINS_FILE = 'toolchains.xml';
|
exports.MVN_TOOLCHAINS_FILE = 'toolchains.xml';
|
||||||
exports.INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id';
|
exports.INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id';
|
||||||
exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor';
|
exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor';
|
||||||
|
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto'];
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
114
dist/setup/index.js
vendored
114
dist/setup/index.js
vendored
|
@ -103582,7 +103582,7 @@ function isProbablyGradleDaemonProblem(packageManager, error) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
|
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
|
||||||
exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
|
exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
|
||||||
exports.INPUT_JAVA_VERSION = 'java-version';
|
exports.INPUT_JAVA_VERSION = 'java-version';
|
||||||
exports.INPUT_JAVA_VERSION_FILE = 'java-version-file';
|
exports.INPUT_JAVA_VERSION_FILE = 'java-version-file';
|
||||||
|
@ -103608,6 +103608,7 @@ exports.MVN_SETTINGS_FILE = 'settings.xml';
|
||||||
exports.MVN_TOOLCHAINS_FILE = 'toolchains.xml';
|
exports.MVN_TOOLCHAINS_FILE = 'toolchains.xml';
|
||||||
exports.INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id';
|
exports.INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id';
|
||||||
exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor';
|
exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor';
|
||||||
|
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto'];
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
@ -105193,8 +105194,8 @@ const constants = __importStar(__nccwpck_require__(9042));
|
||||||
const cache_1 = __nccwpck_require__(4810);
|
const cache_1 = __nccwpck_require__(4810);
|
||||||
const path = __importStar(__nccwpck_require__(1017));
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
const distribution_factory_1 = __nccwpck_require__(924);
|
const distribution_factory_1 = __nccwpck_require__(924);
|
||||||
|
const semver = __importStar(__nccwpck_require__(1383));
|
||||||
function run() {
|
function run() {
|
||||||
var _a, _b, _c, _d;
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION);
|
const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION);
|
||||||
|
@ -105213,34 +105214,28 @@ function run() {
|
||||||
if (!versions.length && !versionFile) {
|
if (!versions.length && !versionFile) {
|
||||||
throw new Error('Java-version or java-version-file input expected');
|
throw new Error('Java-version or java-version-file input expected');
|
||||||
}
|
}
|
||||||
|
const installerInputsOptions = {
|
||||||
|
architecture,
|
||||||
|
packageType,
|
||||||
|
checkLatest,
|
||||||
|
distributionName,
|
||||||
|
jdkFile,
|
||||||
|
toolchainIds
|
||||||
|
};
|
||||||
if (!versions.length) {
|
if (!versions.length) {
|
||||||
core.debug('Java-version input is empty, looking for java-version-file input');
|
core.debug('Java-version input is empty, looking for java-version-file input');
|
||||||
const contents = fs_1.default
|
const content = fs_1.default
|
||||||
.readFileSync(versionFile)
|
.readFileSync(versionFile)
|
||||||
.toString()
|
.toString()
|
||||||
.trim();
|
.trim();
|
||||||
const semverRegExp = /(?<version>(?<=(^|\s|\-))(\d+\S*))(\s|$)/;
|
const version = getVersionFromFileContent(content, distributionName);
|
||||||
let version = ((_b = (_a = contents.match(semverRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version)
|
if (!version) {
|
||||||
? (_d = (_c = contents.match(semverRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version
|
throw new Error(`No supported version was found in file ${versionFile}`);
|
||||||
: '';
|
|
||||||
let installed = false;
|
|
||||||
while (!installed && version) {
|
|
||||||
try {
|
|
||||||
core.debug(`Trying to install version ${version}`);
|
|
||||||
yield installVersion(version);
|
|
||||||
installed = true;
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
core.debug(`${error.toString()}`);
|
|
||||||
version = getHigherVersion(version);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!installed) {
|
|
||||||
throw new Error("Сan't install appropriate version from .java-version file");
|
|
||||||
}
|
}
|
||||||
|
yield installVersion(version, installerInputsOptions);
|
||||||
}
|
}
|
||||||
for (const [index, version] of versions.entries()) {
|
for (const [index, version] of versions.entries()) {
|
||||||
yield installVersion(version, index);
|
yield installVersion(version, installerInputsOptions, index);
|
||||||
}
|
}
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
const matchersPath = path.join(__dirname, '..', '..', '.github');
|
const matchersPath = path.join(__dirname, '..', '..', '.github');
|
||||||
|
@ -105249,33 +105244,6 @@ function run() {
|
||||||
if (cache && util_1.isCacheFeatureAvailable()) {
|
if (cache && util_1.isCacheFeatureAvailable()) {
|
||||||
yield cache_1.restore(cache);
|
yield cache_1.restore(cache);
|
||||||
}
|
}
|
||||||
function installVersion(version, toolchainId = 0) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const installerOptions = {
|
|
||||||
architecture,
|
|
||||||
packageType,
|
|
||||||
version,
|
|
||||||
checkLatest
|
|
||||||
};
|
|
||||||
const distribution = distribution_factory_1.getJavaDistribution(distributionName, installerOptions, jdkFile);
|
|
||||||
if (!distribution) {
|
|
||||||
throw new Error(`No supported distribution was found for input ${distributionName}`);
|
|
||||||
}
|
|
||||||
const result = yield distribution.setupJava();
|
|
||||||
yield toolchains.configureToolchains(version, distributionName, result.path, toolchainIds[toolchainId]);
|
|
||||||
core.info('');
|
|
||||||
core.info('Java configuration:');
|
|
||||||
core.info(` Distribution: ${distributionName}`);
|
|
||||||
core.info(` Version: ${result.version}`);
|
|
||||||
core.info(` Path: ${result.path}`);
|
|
||||||
core.info('');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function getHigherVersion(version) {
|
|
||||||
return version.split('-')[0] === version
|
|
||||||
? version.substring(0, version.lastIndexOf('.'))
|
|
||||||
: version.split('-')[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
|
@ -105283,6 +105251,54 @@ function run() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
run();
|
run();
|
||||||
|
function installVersion(version, options, toolchainId = 0) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const { distributionName, jdkFile, architecture, packageType, checkLatest, toolchainIds } = options;
|
||||||
|
const installerOptions = {
|
||||||
|
architecture,
|
||||||
|
packageType,
|
||||||
|
checkLatest,
|
||||||
|
version
|
||||||
|
};
|
||||||
|
const distribution = distribution_factory_1.getJavaDistribution(distributionName, installerOptions, jdkFile);
|
||||||
|
if (!distribution) {
|
||||||
|
throw new Error(`No supported distribution was found for input ${distributionName}`);
|
||||||
|
}
|
||||||
|
const result = yield distribution.setupJava();
|
||||||
|
yield toolchains.configureToolchains(version, distributionName, result.path, toolchainIds[toolchainId]);
|
||||||
|
core.info('');
|
||||||
|
core.info('Java configuration:');
|
||||||
|
core.info(` Distribution: ${distributionName}`);
|
||||||
|
core.info(` Version: ${result.version}`);
|
||||||
|
core.info(` Path: ${result.path}`);
|
||||||
|
core.info('');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function getVersionFromFileContent(content, distributionName) {
|
||||||
|
var _a, _b, _c, _d;
|
||||||
|
const javaVersionRegExp = /(?<version>(?<=(^|\s|\-))(\d+\S*))(\s|$)/;
|
||||||
|
const fileContent = ((_b = (_a = content.match(javaVersionRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version)
|
||||||
|
? (_d = (_c = content.match(javaVersionRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version
|
||||||
|
: '';
|
||||||
|
if (!fileContent) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const tentativeVersion = avoidOldNotation(fileContent);
|
||||||
|
let version = semver.validRange(tentativeVersion)
|
||||||
|
? tentativeVersion
|
||||||
|
: semver.coerce(tentativeVersion);
|
||||||
|
if (!version) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (constants.DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(distributionName)) {
|
||||||
|
version = semver.major(version).toString();
|
||||||
|
}
|
||||||
|
return version.toString();
|
||||||
|
}
|
||||||
|
// By convention, action expects version 8 in the format `8.*` instead of `1.8`
|
||||||
|
function avoidOldNotation(content) {
|
||||||
|
return content.substring(0, 2) === '1.' ? content.substring(2) : content;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
|
@ -28,4 +28,4 @@ export const MVN_TOOLCHAINS_FILE = 'toolchains.xml';
|
||||||
export const INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id';
|
export const INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id';
|
||||||
export const INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor';
|
export const INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor';
|
||||||
|
|
||||||
export const DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto']
|
export const DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto'];
|
||||||
|
|
|
@ -48,7 +48,7 @@ async function run() {
|
||||||
.toString()
|
.toString()
|
||||||
.trim();
|
.trim();
|
||||||
|
|
||||||
const version = getVersionFromFileContent(content, distributionName)
|
const version = getVersionFromFileContent(content, distributionName);
|
||||||
|
|
||||||
if (!version) {
|
if (!version) {
|
||||||
throw new Error(`No supported version was found in file ${versionFile}`);
|
throw new Error(`No supported version was found in file ${versionFile}`);
|
||||||
|
@ -128,7 +128,7 @@ function getVersionFromFileContent(content: string, distributionName: string): s
|
||||||
? (content.match(javaVersionRegExp)?.groups?.version as string)
|
? (content.match(javaVersionRegExp)?.groups?.version as string)
|
||||||
: '';
|
: '';
|
||||||
if (!fileContent) {
|
if (!fileContent) {
|
||||||
return null
|
return null;
|
||||||
}
|
}
|
||||||
const tentativeVersion = avoidOldNotation(fileContent);
|
const tentativeVersion = avoidOldNotation(fileContent);
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ function getVersionFromFileContent(content: string, distributionName: string): s
|
||||||
: semver.coerce(tentativeVersion);
|
: semver.coerce(tentativeVersion);
|
||||||
|
|
||||||
if (!version) {
|
if (!version) {
|
||||||
return null
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (constants.DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(distributionName)) {
|
if (constants.DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(distributionName)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue