| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Toolchain generation was gated behind the `overwrite-settings` input, which is documented to control only regeneration of `settings.xml`. Because `generateToolchainDefinition` already performs a non-destructive merge (existing JDK, custom, and user-managed toolchains are preserved, and only an entry with the same `type` + `provides.id` is replaced), skipping the write when `overwrite-settings: false` caused later setup-java executions to drop toolchain entries registered by earlier runs. Decouple toolchains generation from `overwrite-settings`: the toolchains file is now always written, so consecutive runs accumulate every JDK. `settings.xml` behavior (auth.ts) is unchanged. - src/toolchains.ts: drop overwriteSettings from configureToolchains / createToolchainsSettings / writeToolchainsFileToDisk; always write. - __tests__/toolchains.test.ts: update call sites, rewrite the "does not overwrite" test to assert non-destructive extension, and add a regression test for consecutive configureToolchains executions. - docs/advanced-usage.md: clarify merge is non-destructive and independent of overwrite-settings. - dist/setup/index.js: rebuilt. Fixes #1099 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0bcec457-b86b-4902-b6e6-6dfd6b2570f7
There was a problem hiding this comment.
This PR fixes a regression where running actions/setup-java multiple times within the same job could cause Maven ~/.m2/toolchains.xml to lose previously-registered JDK toolchain entries. It makes toolchains persistence independent of the overwrite-settings input (which is intended to control settings.xml only), relying on the existing non-destructive merge behavior when generating toolchains.
Changes:
| File | Description |
|---|---|
| src/toolchains.ts | Removes overwrite-settings gating so toolchains are always persisted after merge. |
| __tests__/toolchains.test.ts | Updates call sites and adds regression coverage for repeated runs preserving all toolchains. |
| docs/advanced-usage.md | Documents that toolchains merging is non-destructive and independent of overwrite-settings. |
| dist/setup/index.js | Rebuilt distribution output reflecting the source changes. |
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@lmvysakh can you please review this? |
Sorry, something went wrong.
|
@brunoborges This PR will raise a conflict to my #1109 one I guess. |
Sorry, something went wrong.
|
Hy @brunoborges , Reviewed and Approved PR. |
Sorry, something went wrong.
…runs (#1099) (#1113) * Preserve Maven toolchains across repeated setup-java runs (#1099) Backport of #1111 to releases/v5. Toolchain generation was gated behind the `overwrite-settings` input, which is documented to control only regeneration of `settings.xml`. Because `generateToolchainDefinition` already performs a non-destructive merge (existing JDK, custom, and user-managed toolchains are preserved, and only an entry with the same `type` + `provides.id` is replaced), skipping the write when `overwrite-settings: false` caused later setup-java executions to drop toolchain entries registered by earlier runs. Decouple toolchains generation from `overwrite-settings`: the toolchains file is now always written, so consecutive runs accumulate every JDK. `settings.xml` behavior (auth.ts) is unchanged. - src/toolchains.ts: drop overwriteSettings from configureToolchains / createToolchainsSettings / writeToolchainsFileToDisk; always write. - __tests__/toolchains.test.ts: update call sites, rewrite the "does not overwrite" test to assert non-destructive extension, and add a regression test for consecutive configureToolchains executions. - docs/advanced-usage.md: clarify merge is non-destructive and independent of overwrite-settings. - dist/setup/index.js: rebuilt. Fixes #1099 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
##### [vv5.6.0](https://github.com/actions/setup-java/releases/tag/v5.6.0) #### What's Changed - Backport to v5: Add Maven compiler problem matcher for javac diagnostics by [@brunoborges](https://github.com/brunoborges) in [#1087](actions/setup-java#1087) - feat: expose cache-primary-key output ([#597](actions/setup-java#597)) \[v5 backport] by [@brunoborges](https://github.com/brunoborges) in [#1089](actions/setup-java#1089) - dist: Cover Tencent Kona JDK 25 ([#1108](actions/setup-java#1108)) \[v5 backport] by [@brunoborges](https://github.com/brunoborges) in [#1110](actions/setup-java#1110) - Backport [#1111](actions/setup-java#1111): Preserve Maven toolchains across repeated setup-java runs ([#1099](actions/setup-java#1099)) by [@brunoborges](https://github.com/brunoborges) in [#1113](actions/setup-java#1113) - Backport [#1097](https://github.com/actions/setup-java/issues/1097)/[#1098](https://github.com/actions/setup-java/issues/1098) to v5: cache Maven and Gradle wrapper distributions separately by [@brunoborges](https://github.com/brunoborges) in [#1122](actions/setup-java#1122) **Full Changelog**: <actions/setup-java@v5...v5.6.0> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
Summary
Fixes #1099. Running setup-java multiple times in the same job (matrix builds or multiple java-version values) could drop toolchain entries registered by earlier runs, leaving only one JDK in ~/.m2/toolchains.xml.
Root cause
Toolchains generation was gated behind the overwrite-settings input. When overwrite-settings: false, writeToolchainsFileToDisk skipped writing entirely if the file already existed — so a second setup-java run never persisted its JDK, silently discarding the merged result.
This gating was inappropriate because:
So writing the toolchains file is always safe and should not be blocked.
Changes
Testing
Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com