install version from file
This commit is contained in:
parent
5a37903655
commit
f8c67ed9c3
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 cache = core.getInput(constants.INPUT_CACHE);
|
||||||
const checkLatest = util_1.getBooleanInput(constants.INPUT_CHECK_LATEST, false);
|
const checkLatest = util_1.getBooleanInput(constants.INPUT_CHECK_LATEST, false);
|
||||||
let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID);
|
let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID);
|
||||||
|
core.startGroup('Installed distributions');
|
||||||
|
if (versions.length !== toolchainIds.length) {
|
||||||
|
toolchainIds = [];
|
||||||
|
}
|
||||||
if (!versions.length) {
|
if (!versions.length) {
|
||||||
core.debug("JAVA_VERSION input is empty, looking for .java-version file");
|
core.debug("JAVA_VERSION input is empty, looking for .java-version file");
|
||||||
const versionFileName = '.java-version';
|
const versionFileName = '.java-version';
|
||||||
@ -105064,32 +105068,20 @@ function run() {
|
|||||||
const version = semverRegExp.test(contents) ? RegExp.$1 : "";
|
const version = semverRegExp.test(contents) ? RegExp.$1 : "";
|
||||||
const coercedVer = semver.coerce(version);
|
const coercedVer = semver.coerce(version);
|
||||||
const validVer = semver.valid(coercedVer);
|
const validVer = semver.valid(coercedVer);
|
||||||
core.info(validVer ? validVer : "not found");
|
if (validVer === null) {
|
||||||
versions.push(contents);
|
throw new Error("No version found");
|
||||||
}
|
|
||||||
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}`);
|
|
||||||
}
|
}
|
||||||
const result = yield distribution.setupJava();
|
const stringVersion = validVer;
|
||||||
yield toolchains.configureToolchains(version, distributionName, result.path, toolchainIds[index]);
|
try {
|
||||||
core.info('');
|
installVersion(stringVersion);
|
||||||
core.info('Java configuration:');
|
}
|
||||||
core.info(` Distribution: ${distributionName}`);
|
catch (error) {
|
||||||
core.info(` Version: ${result.version}`);
|
core.info(`${stringVersion} not found`);
|
||||||
core.info(` Path: ${result.path}`);
|
throw new Error("some err");
|
||||||
core.info('');
|
}
|
||||||
|
}
|
||||||
|
for (const [index, version] of versions.entries()) {
|
||||||
|
yield installVersion(version, index);
|
||||||
}
|
}
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
const matchersPath = path.join(__dirname, '..', '..', '.github');
|
const matchersPath = path.join(__dirname, '..', '..', '.github');
|
||||||
@ -105098,6 +105090,28 @@ 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('');
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
|
@ -21,6 +21,12 @@ async function run() {
|
|||||||
const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false);
|
const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false);
|
||||||
let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID);
|
let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID);
|
||||||
|
|
||||||
|
core.startGroup('Installed distributions');
|
||||||
|
|
||||||
|
if (versions.length !== toolchainIds.length) {
|
||||||
|
toolchainIds = [];
|
||||||
|
}
|
||||||
|
|
||||||
if (!versions.length) {
|
if (!versions.length) {
|
||||||
core.debug("JAVA_VERSION input is empty, looking for .java-version file")
|
core.debug("JAVA_VERSION input is empty, looking for .java-version file")
|
||||||
const versionFileName = '.java-version'
|
const versionFileName = '.java-version'
|
||||||
@ -29,16 +35,31 @@ async function run() {
|
|||||||
const version = semverRegExp.test(contents) ? RegExp.$1 : "";
|
const version = semverRegExp.test(contents) ? RegExp.$1 : "";
|
||||||
const coercedVer = semver.coerce(version)
|
const coercedVer = semver.coerce(version)
|
||||||
const validVer = semver.valid(coercedVer)
|
const validVer = semver.valid(coercedVer)
|
||||||
core.info(validVer ? validVer as string : "not found")
|
if (validVer === null) {
|
||||||
versions.push(contents)
|
throw new Error("No version found")
|
||||||
|
}
|
||||||
|
const stringVersion = validVer as string;
|
||||||
|
try {
|
||||||
|
installVersion(stringVersion)
|
||||||
|
} catch (error) {
|
||||||
|
core.info(`${stringVersion} not found`)
|
||||||
|
throw new Error("some err")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (versions.length !== toolchainIds.length) {
|
|
||||||
toolchainIds = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
core.startGroup('Installed distributions');
|
|
||||||
for (const [index, version] of versions.entries()) {
|
for (const [index, version] of versions.entries()) {
|
||||||
|
await installVersion(version, index)
|
||||||
|
}
|
||||||
|
core.endGroup();
|
||||||
|
const matchersPath = path.join(__dirname, '..', '..', '.github');
|
||||||
|
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
|
||||||
|
|
||||||
|
await auth.configureAuthentication();
|
||||||
|
if (cache && isCacheFeatureAvailable()) {
|
||||||
|
await restore(cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function installVersion(version:string, toolchainId = 0 ) {
|
||||||
const installerOptions: JavaInstallerOptions = {
|
const installerOptions: JavaInstallerOptions = {
|
||||||
architecture,
|
architecture,
|
||||||
packageType,
|
packageType,
|
||||||
@ -56,7 +77,7 @@ async function run() {
|
|||||||
version,
|
version,
|
||||||
distributionName,
|
distributionName,
|
||||||
result.path,
|
result.path,
|
||||||
toolchainIds[index]
|
toolchainIds[toolchainId]
|
||||||
);
|
);
|
||||||
|
|
||||||
core.info('');
|
core.info('');
|
||||||
@ -66,14 +87,6 @@ async function run() {
|
|||||||
core.info(` Path: ${result.path}`);
|
core.info(` Path: ${result.path}`);
|
||||||
core.info('');
|
core.info('');
|
||||||
}
|
}
|
||||||
core.endGroup();
|
|
||||||
const matchersPath = path.join(__dirname, '..', '..', '.github');
|
|
||||||
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
|
|
||||||
|
|
||||||
await auth.configureAuthentication();
|
|
||||||
if (cache && isCacheFeatureAvailable()) {
|
|
||||||
await restore(cache);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user