MCPcopy
hub / github.com/actions/setup-java / run

Function run

src/setup-java.ts:16–88  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14import {JavaInstallerOptions} from './distributions/base-models';
15
16async function run() {
17 try {
18 const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION);
19 const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, {
20 required: true
21 });
22 const versionFile = core.getInput(constants.INPUT_JAVA_VERSION_FILE);
23 const architecture = core.getInput(constants.INPUT_ARCHITECTURE);
24 const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
25 const jdkFile = core.getInput(constants.INPUT_JDK_FILE);
26 const cache = core.getInput(constants.INPUT_CACHE);
27 const cacheDependencyPath = core.getInput(
28 constants.INPUT_CACHE_DEPENDENCY_PATH
29 );
30 const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false);
31 let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID);
32
33 core.startGroup('Installed distributions');
34
35 if (versions.length !== toolchainIds.length) {
36 toolchainIds = [];
37 }
38
39 if (!versions.length && !versionFile) {
40 throw new Error('java-version or java-version-file input expected');
41 }
42
43 const installerInputsOptions: installerInputsOptions = {
44 architecture,
45 packageType,
46 checkLatest,
47 distributionName,
48 jdkFile,
49 toolchainIds
50 };
51
52 if (!versions.length) {
53 core.debug(
54 'java-version input is empty, looking for java-version-file input'
55 );
56 const content = fs.readFileSync(versionFile).toString().trim();
57
58 const version = getVersionFromFileContent(
59 content,
60 distributionName,
61 versionFile
62 );
63 core.debug(`Parsed version from file '${version}'`);
64
65 if (!version) {
66 throw new Error(
67 `No supported version was found in file ${versionFile}`
68 );
69 }
70
71 await installVersion(version, installerInputsOptions);
72 }
73

Callers 1

setup-java.tsFile · 0.70

Calls 5

getBooleanInputFunction · 0.90
isCacheFeatureAvailableFunction · 0.90
restoreFunction · 0.90
installVersionFunction · 0.85

Tested by

no test coverage detected