Skip to content

feat: Add distribution detection support to .sdkmanrc file#975

Open
lukaszgyg wants to merge 3 commits intoactions:mainfrom
lukaszgyg:feat/sdkmanrc-distribution-support
Open

feat: Add distribution detection support to .sdkmanrc file#975
lukaszgyg wants to merge 3 commits intoactions:mainfrom
lukaszgyg:feat/sdkmanrc-distribution-support

Conversation

@lukaszgyg
Copy link

@lukaszgyg lukaszgyg commented Jan 24, 2026

Summary

Extends the existing .sdkmanrc support to automatically detect and use the Java distribution identifier from SDKMAN version strings (for example, java=21.0.5-tem).

Related Issue

#971

Changes

  • Enhanced .sdkmanrc parsing to extract both the version and the distribution identifier
  • Added SDKMAN distribution identifier mapping to setup-java distribution names, including:
    • tem -> temurin
    • sem -> semeru
    • albba/dragonwell -> dragonwell
    • zulu -> zulu
    • amzn -> corretto
    • graal/graalce -> graalvm
    • librca -> liberica
    • ms -> microsoft
    • oracle -> oracle
    • sapmchn -> sapmachine
    • jbr -> jetbrains
  • Made distribution input optional when .sdkmanrc includes a supported distribution suffix
  • Added unit coverage for supported SDKMAN identifiers, unknown identifiers, and missing suffixes
  • Regenerated dist after the source changes

Usage

Before (distribution required):

- uses: actions/setup-java@main
  with:
    distribution: temurin
    java-version-file: .sdkmanrc

After (distribution auto-detected):

- uses: actions/setup-java@main
  with:
    java-version-file: .sdkmanrc

.sdkmanrc file:

java=21.0.5-tem

Backward Compatibility

  • Fully backward compatible with existing configurations
  • When .sdkmanrc does not include a supported distribution suffix, the distribution input is still required
  • Existing workflows without distribution suffix continue to work unchanged

Testing

  • npm run format-check
  • npm run lint
  • npm run build
  • npm test -- --runInBand __tests__/util.test.ts
  • npm test locally; all suites passed except one unrelated JetBrains network lookup failure in __tests__/distributors/jetbrains-installer.test.ts

@lukaszgyg lukaszgyg requested a review from a team as a code owner January 24, 2026 10:25
Copilot AI review requested due to automatic review settings January 24, 2026 10:25
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends .sdkmanrc file support to automatically detect and use Java distribution identifiers from SDKMAN version strings (e.g., java=21.0.5-tem), making the distribution input optional when a distribution suffix is present.

Changes:

  • Enhanced .sdkmanrc parsing to extract both version and distribution identifier
  • Added SDKMAN-to-setup-java distribution mapping for 10 distributions (Temurin, Zulu, Corretto, GraalVM, Liberica, Microsoft, Oracle, SapMachine, JetBrains, Dragonwell)
  • Made distribution input optional in action.yml when distribution can be detected from file
  • Updated return type of getVersionFromFileContent from string to VersionInfo object containing version and optional distribution
  • Modified setup logic to prefer file-extracted distribution over input parameter

Reviewed changes

Copilot reviewed 6 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/util.ts Added VersionInfo interface, updated getVersionFromFileContent to return version and distribution, added mapSdkmanDistribution function with SDKMAN identifier mappings
src/setup-java.ts Modified to handle optional distribution input, prioritize file-extracted distribution, refactored installation logic
action.yml Updated distribution input to be optional with clarified description
tests/util.test.ts Updated test assertions to match new VersionInfo return type, added tests for various distribution identifiers
.sdkmanrc.example Added example file demonstrating supported SDKMAN distribution identifiers
.github/workflows/sdkmanrc-example.yml Added workflow examples showing usage with and without distribution suffix
dist/setup/index.js Compiled source changes for setup entry point
dist/cleanup/index.js Compiled source changes for cleanup entry point
package-lock.json Updated peer dependency flags (normal npm behavior)

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

Extends .sdkmanrc support to automatically detect Java distribution from SDKMAN identifiers (e.g., java=21.0.5-tem maps to temurin distribution).

Makes distribution input optional when using .sdkmanrc with distribution suffix.
@lukaszgyg lukaszgyg force-pushed the feat/sdkmanrc-distribution-support branch from 9eddd18 to d2b3ef8 Compare January 24, 2026 10:53
@bschulz-nf
Copy link

would be great if someone could review this PR. Having to specify the JDK vendor twice is actually improvable.

At the moment users have to specify the JDK vendor e.g. Temurin in the sdkman.rc file like "25.0.1-tem" so sdkman picks up the Temurin JDK and also explicitly add a distribution entry containing "temurin" in the github action as well.

@lukaszgyg
Copy link
Author

Addressed the review feedback and updated the PR description. The branch now includes sem -> semeru, albba -> dragonwell, additional SDKMAN coverage, and regenerated dist. Ready for another look.

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.

4 participants