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:
Bruno Borges
2026-07-28 23:33:41 -04:00
committed by GitHub
parent ce75feb3d3
commit e1ce3a3428
7 changed files with 100 additions and 12 deletions
+11 -4
View File
@@ -128876,6 +128876,15 @@ async function write(directory, settings, overwriteSettings) {
function validateToolchainIds(versions, versionFile, toolchainIds) {
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})`);
}
}
async function configureToolchains(version, distributionName, jdkHome, toolchainId) {
const vendor = getInput(INPUT_MVN_TOOLCHAIN_VENDOR) || distributionName;
const id = toolchainId || `${vendor}_${version}`;
@@ -132202,14 +132211,12 @@ async function run() {
const setDefault = util_getBooleanInput(INPUT_SET_DEFAULT, true);
const verifySignature = util_getBooleanInput(INPUT_VERIFY_SIGNATURE, false);
const verifySignaturePublicKey = getInput(INPUT_VERIFY_SIGNATURE_PUBLIC_KEY) || undefined;
let toolchainIds = getMultilineInput(INPUT_MVN_TOOLCHAIN_ID);
const toolchainIds = getMultilineInput(INPUT_MVN_TOOLCHAIN_ID);
startGroup('Installed distributions');
if (versions.length !== toolchainIds.length) {
toolchainIds = [];
}
if (!versions.length && !versionFile) {
throw new Error('java-version or java-version-file input expected');
}
validateToolchainIds(versions, versionFile, toolchainIds);
if (!versions.length) {
core_debug('java-version input is empty, looking for java-version-file input');
const content = external_fs_default().readFileSync(versionFile).toString().trim();