Dedupe setJavaDefault and document multi-version/toolchain behavior

- Refactor setJavaDefault to delegate shared output/env logic to
  setJavaEnvironment, avoiding duplication between the two.
- Document that set-default applies to all JDKs in a multiline
  java-version, and that installed JDKs remain registered in Maven
  toolchains regardless of set-default.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Bruno Borges
2026-06-22 17:08:46 -04:00
committed by GitHub
parent 9eb9a7c9b3
commit 8b504c3bad
3 changed files with 8 additions and 15 deletions
+5 -7
View File
@@ -78309,7 +78309,6 @@ const constants_1 = __nccwpck_require__(27242);
const os_1 = __importDefault(__nccwpck_require__(70857));
class JavaBase {
constructor(distribution, installerOptions) {
var _a;
this.distribution = distribution;
this.http = new httpm.HttpClient('actions/setup-java', undefined, {
allowRetries: true,
@@ -78319,7 +78318,10 @@ class JavaBase {
this.architecture = installerOptions.architecture || os_1.default.arch();
this.packageType = installerOptions.packageType;
this.checkLatest = installerOptions.checkLatest;
this.setDefault = (_a = installerOptions.setDefault) !== null && _a !== void 0 ? _a : true;
this.setDefault =
installerOptions.setDefault !== undefined
? installerOptions.setDefault
: true;
}
setupJava() {
var _a, _b;
@@ -78540,13 +78542,9 @@ class JavaBase {
return error;
}
setJavaDefault(version, toolPath) {
const majorVersion = version.split('.')[0];
core.exportVariable('JAVA_HOME', toolPath);
core.addPath(path_1.default.join(toolPath, 'bin'));
core.setOutput('distribution', this.distribution);
core.setOutput('path', toolPath);
core.setOutput('version', version);
core.exportVariable(`JAVA_HOME_${majorVersion}_${this.architecture.toUpperCase()}`, toolPath);
this.setJavaEnvironment(version, toolPath);
}
setJavaEnvironment(version, toolPath) {
const majorVersion = version.split('.')[0];