Skip to content

Fail when Maven toolchain ID count does not match Java versions #1156

Description

@brunoborges

Description:
When multiple Java versions are configured and the number of mvn-toolchain-id entries differs from the number of java-version entries, the action silently discards every supplied custom ID and generates defaults. This hides workflow configuration mistakes and can select an unexpected Maven toolchain.

Validate the relationship before installing any JDK. If mvn-toolchain-id is supplied, require exactly one ID per configured Java version and report both counts in the error. Add unit tests for matching, missing, and extra IDs, including single-version and java-version-file usage.

Task version:
v6

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Repro steps:
Configure two Java versions but only one custom toolchain ID:

- uses: actions/setup-java@v6
  with:
    distribution: temurin
    java-version: |
      17
      21
    mvn-toolchain-id: custom-jdk

Expected behavior:
The action fails before installation with a descriptive message that two Java versions require two Maven toolchain IDs.

Actual behavior:
The supplied ID is silently discarded and both toolchains receive generated default IDs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions