mirror of
https://github.com/actions/setup-java.git
synced 2026-08-01 16:22:58 +00:00
Fail on mismatched Maven toolchain ID counts (#1161)
* Fail on mismatched Maven toolchain IDs Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8c821981-7b21-45fe-9463-5bb375d7dce4 * Clarify Maven toolchain ID version counts Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8c821981-7b21-45fe-9463-5bb375d7dce4 --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8c821981-7b21-45fe-9463-5bb375d7dce4
This commit is contained in:
+5
-5
@@ -40,18 +40,18 @@ async function run() {
|
||||
);
|
||||
const verifySignaturePublicKey =
|
||||
core.getInput(constants.INPUT_VERIFY_SIGNATURE_PUBLIC_KEY) || undefined;
|
||||
let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID);
|
||||
const toolchainIds = core.getMultilineInput(
|
||||
constants.INPUT_MVN_TOOLCHAIN_ID
|
||||
);
|
||||
|
||||
core.startGroup('Installed distributions');
|
||||
|
||||
if (versions.length !== toolchainIds.length) {
|
||||
toolchainIds = [];
|
||||
}
|
||||
|
||||
if (!versions.length && !versionFile) {
|
||||
throw new Error('java-version or java-version-file input expected');
|
||||
}
|
||||
|
||||
toolchains.validateToolchainIds(versions, versionFile, toolchainIds);
|
||||
|
||||
if (!versions.length) {
|
||||
core.debug(
|
||||
'java-version input is empty, looking for java-version-file input'
|
||||
|
||||
@@ -14,6 +14,23 @@ interface JdkInfo {
|
||||
jdkHome: string;
|
||||
}
|
||||
|
||||
export function validateToolchainIds(
|
||||
versions: string[],
|
||||
versionFile: string,
|
||||
toolchainIds: string[]
|
||||
) {
|
||||
if (!toolchainIds.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const versionCount = versions.length || (versionFile ? 1 : 0);
|
||||
if (versionCount !== toolchainIds.length) {
|
||||
throw new Error(
|
||||
`The number of Maven toolchain IDs (${toolchainIds.length}) must match the number of Java versions (${versionCount})`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export async function configureToolchains(
|
||||
version: string,
|
||||
distributionName: string,
|
||||
|
||||
Reference in New Issue
Block a user