Skip to content

Fail on mismatched Maven toolchain ID counts - #1161

Merged
brunoborges merged 2 commits into
mainfrom
brunoborges-validate-maven-toolchain-ids
Jul 29, 2026
Merged

Fail on mismatched Maven toolchain ID counts#1161
brunoborges merged 2 commits into
mainfrom
brunoborges-validate-maven-toolchain-ids

Conversation

@brunoborges

Copy link
Copy Markdown
Contributor

Description:
When custom Maven toolchain IDs do not map one-to-one to configured Java versions, setup-java currently discards them and silently generates defaults. This change validates the counts before any JDK installation, reports both counts on mismatch, and treats java-version-file as one configured version while preserving generated IDs when the input is omitted.

The input documentation, regression tests, and bundled action runtime are updated with the new behavior.

Related issue:
Fixes: #1156

Check list:

  • Ran npm run check locally (format, lint, build, test) and all checks pass.
  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 8c821981-7b21-45fe-9463-5bb375d7dce4
Copilot AI review requested due to automatic review settings July 29, 2026 02:58
@brunoborges
brunoborges requested a review from a team as a code owner July 29, 2026 02:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request tightens actions/setup-java validation around Maven toolchain IDs so misconfigured workflows fail early instead of silently falling back to generated defaults, aligning behavior with the documented one-to-one mapping expectation.

Changes:

  • Add validateToolchainIds and invoke it before any JDK installation to enforce toolchain ID count matches configured Java versions (including java-version-file counting as one version).
  • Update documentation and action.yml input descriptions to reflect the new validation behavior.
  • Add regression tests for valid and invalid toolchain ID count scenarios.
Show a summary per file
File Description
src/toolchains.ts Adds validateToolchainIds count validation logic.
src/setup-java.ts Calls toolchain ID validation during input processing.
README.md Documents the new toolchain ID count requirement.
docs/advanced-usage.md Updates advanced usage guidance for multi-version toolchain IDs.
dist/setup/index.js Updates bundled runtime to include the new validation behavior.
action.yml Updates input description to document the stricter validation.
tests/toolchains.test.ts Adds unit tests for validateToolchainIds.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 6/7 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment thread docs/advanced-usage.md Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8c821981-7b21-45fe-9463-5bb375d7dce4
@brunoborges
brunoborges merged commit e1ce3a3 into main Jul 29, 2026
440 checks passed
@brunoborges
brunoborges deleted the brunoborges-validate-maven-toolchain-ids branch July 29, 2026 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fail when Maven toolchain ID count does not match Java versions

2 participants