diff --git a/dist/setup/index.js b/dist/setup/index.js index b7a59fab..61fb41e2 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -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]; diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 31177067..c99e461d 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -294,6 +294,8 @@ steps: In this example, `JAVA_HOME` and `java` on `PATH` point to Java 17, while Java 21 is available via `JAVA_HOME_21_X64` or the step output `path`. +> **Note:** When a single step installs multiple JDKs via a multiline `java-version`, the `set-default` value applies to all of them. With `set-default: false`, none of those JDKs become the default; each remains discoverable through its `JAVA_HOME__` variable. Regardless of `set-default`, installed JDKs are still registered in the Maven toolchains file, so they can be selected via Maven toolchains. + ## Installing Java from local file If your use-case requires a custom distribution or a version that is not provided by setup-java, you can download it manually and setup-java will take care of the installation and caching on the VM: diff --git a/src/distributions/base-installer.ts b/src/distributions/base-installer.ts index 0f99a49d..09f4b7a1 100644 --- a/src/distributions/base-installer.ts +++ b/src/distributions/base-installer.ts @@ -310,16 +310,9 @@ export abstract class JavaBase { } protected setJavaDefault(version: string, toolPath: string) { - const majorVersion = version.split('.')[0]; core.exportVariable('JAVA_HOME', toolPath); core.addPath(path.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); } protected setJavaEnvironment(version: string, toolPath: string) {