mirror of
https://github.com/actions/setup-java.git
synced 2025-04-20 09:56:46 +00:00
install version from file
This commit is contained in:
parent
5a37903655
commit
f8c67ed9c3
2 changed files with 68 additions and 41 deletions
64
dist/setup/index.js
vendored
64
dist/setup/index.js
vendored
|
@ -105056,6 +105056,10 @@ function run() {
|
|||
const cache = core.getInput(constants.INPUT_CACHE);
|
||||
const checkLatest = util_1.getBooleanInput(constants.INPUT_CHECK_LATEST, false);
|
||||
let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID);
|
||||
core.startGroup('Installed distributions');
|
||||
if (versions.length !== toolchainIds.length) {
|
||||
toolchainIds = [];
|
||||
}
|
||||
if (!versions.length) {
|
||||
core.debug("JAVA_VERSION input is empty, looking for .java-version file");
|
||||
const versionFileName = '.java-version';
|
||||
|
@ -105064,32 +105068,20 @@ function run() {
|
|||
const version = semverRegExp.test(contents) ? RegExp.$1 : "";
|
||||
const coercedVer = semver.coerce(version);
|
||||
const validVer = semver.valid(coercedVer);
|
||||
core.info(validVer ? validVer : "not found");
|
||||
versions.push(contents);
|
||||
}
|
||||
if (versions.length !== toolchainIds.length) {
|
||||
toolchainIds = [];
|
||||
}
|
||||
core.startGroup('Installed distributions');
|
||||
for (const [index, version] of versions.entries()) {
|
||||
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}`);
|
||||
if (validVer === null) {
|
||||
throw new Error("No version found");
|
||||
}
|
||||
const result = yield distribution.setupJava();
|
||||
yield toolchains.configureToolchains(version, distributionName, result.path, toolchainIds[index]);
|
||||
core.info('');
|
||||
core.info('Java configuration:');
|
||||
core.info(` Distribution: ${distributionName}`);
|
||||
core.info(` Version: ${result.version}`);
|
||||
core.info(` Path: ${result.path}`);
|
||||
core.info('');
|
||||
const stringVersion = validVer;
|
||||
try {
|
||||
installVersion(stringVersion);
|
||||
}
|
||||
catch (error) {
|
||||
core.info(`${stringVersion} not found`);
|
||||
throw new Error("some err");
|
||||
}
|
||||
}
|
||||
for (const [index, version] of versions.entries()) {
|
||||
yield installVersion(version, index);
|
||||
}
|
||||
core.endGroup();
|
||||
const matchersPath = path.join(__dirname, '..', '..', '.github');
|
||||
|
@ -105098,6 +105090,28 @@ function run() {
|
|||
if (cache && util_1.isCacheFeatureAvailable()) {
|
||||
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('');
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue