mirror of
https://github.com/actions/setup-java.git
synced 2026-07-10 15:35:36 +00:00
Merge remote-tracking branch 'origin/main' into brunoborges-infer-distribution-from-tool-versions
This commit is contained in:
commit
54eb552199
5
.github/workflows/e2e-local-file.yml
vendored
5
.github/workflows/e2e-local-file.yml
vendored
@ -47,7 +47,7 @@ jobs:
|
|||||||
id: setup-java
|
id: setup-java
|
||||||
with:
|
with:
|
||||||
distribution: 'jdkfile'
|
distribution: 'jdkfile'
|
||||||
jdkFile: ${{ runner.temp }}/${{ env.LocalFilename }}
|
jdk-file: ${{ runner.temp }}/${{ env.LocalFilename }}
|
||||||
java-version: '11.0.0-ea'
|
java-version: '11.0.0-ea'
|
||||||
architecture: x64
|
architecture: x64
|
||||||
- name: Verify Java version
|
- name: Verify Java version
|
||||||
@ -88,7 +88,7 @@ jobs:
|
|||||||
id: setup-java
|
id: setup-java
|
||||||
with:
|
with:
|
||||||
distribution: 'jdkfile'
|
distribution: 'jdkfile'
|
||||||
jdkFile: ${{ runner.temp }}/${{ env.LocalFilename }}
|
jdk-file: ${{ runner.temp }}/${{ env.LocalFilename }}
|
||||||
java-version: '11.0.0-ea'
|
java-version: '11.0.0-ea'
|
||||||
architecture: x64
|
architecture: x64
|
||||||
- name: Verify Java version
|
- name: Verify Java version
|
||||||
@ -129,6 +129,7 @@ jobs:
|
|||||||
id: setup-java
|
id: setup-java
|
||||||
with:
|
with:
|
||||||
distribution: 'jdkfile'
|
distribution: 'jdkfile'
|
||||||
|
# Intentionally uses the deprecated `jdkFile` alias to keep it covered.
|
||||||
jdkFile: ${{ runner.temp }}/${{ env.LocalFilename }}
|
jdkFile: ${{ runner.temp }}/${{ env.LocalFilename }}
|
||||||
java-version: '11.0.0-ea'
|
java-version: '11.0.0-ea'
|
||||||
architecture: x64
|
architecture: x64
|
||||||
|
|||||||
@ -41,7 +41,7 @@ For more details, see the full release notes on the [releases page](https://git
|
|||||||
|
|
||||||
- `architecture`: The target architecture of the package. Possible values: `x86`, `x64`, `armv7`, `aarch64`, `ppc64le`. Default value: Derived from the runner machine.
|
- `architecture`: The target architecture of the package. Possible values: `x86`, `x64`, `armv7`, `aarch64`, `ppc64le`. Default value: Derived from the runner machine.
|
||||||
|
|
||||||
- `jdkFile`: If a use-case requires a custom distribution setup-java uses the compressed JDK from the location pointed by this input and will take care of the installation and caching on the VM. Note: `distribution` must be set to 'jdkfile' (case-sensitive; all lowercase) when using this option.
|
- `jdk-file`: If a use-case requires a custom distribution setup-java uses the compressed JDK from the location pointed by this input and will take care of the installation and caching on the VM. Note: `distribution` must be set to 'jdkfile' (case-sensitive; all lowercase) when using this option. (The camelCase `jdkFile` input is still accepted as a deprecated alias and may be removed in a future release.)
|
||||||
|
|
||||||
- `check-latest`: Setting this option makes the action to check for the latest available version for the version spec.
|
- `check-latest`: Setting this option makes the action to check for the latest available version for the version spec.
|
||||||
|
|
||||||
|
|||||||
@ -19,9 +19,13 @@ inputs:
|
|||||||
architecture:
|
architecture:
|
||||||
description: "The architecture of the package (defaults to the action runner's architecture)"
|
description: "The architecture of the package (defaults to the action runner's architecture)"
|
||||||
required: false
|
required: false
|
||||||
jdkFile:
|
jdk-file:
|
||||||
description: 'Path to where the compressed JDK is located'
|
description: 'Path to where the compressed JDK is located'
|
||||||
required: false
|
required: false
|
||||||
|
jdkFile:
|
||||||
|
description: 'Deprecated alias for `jdk-file`. Path to where the compressed JDK is located. Use `jdk-file` instead; this alias may be removed in a future release.'
|
||||||
|
required: false
|
||||||
|
deprecationMessage: 'The `jdkFile` input is deprecated. Use `jdk-file` instead.'
|
||||||
check-latest:
|
check-latest:
|
||||||
description: 'Set this option if you want the action to check for the latest available version that satisfies the version spec'
|
description: 'Set this option if you want the action to check for the latest available version that satisfies the version spec'
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
5
dist/cleanup/index.js
vendored
5
dist/cleanup/index.js
vendored
@ -95834,7 +95834,8 @@ const INPUT_JAVA_VERSION_FILE = 'java-version-file';
|
|||||||
const INPUT_ARCHITECTURE = 'architecture';
|
const INPUT_ARCHITECTURE = 'architecture';
|
||||||
const INPUT_JAVA_PACKAGE = 'java-package';
|
const INPUT_JAVA_PACKAGE = 'java-package';
|
||||||
const INPUT_DISTRIBUTION = 'distribution';
|
const INPUT_DISTRIBUTION = 'distribution';
|
||||||
const INPUT_JDK_FILE = 'jdkFile';
|
const INPUT_JDK_FILE = 'jdk-file';
|
||||||
|
const INPUT_JDK_FILE_DEPRECATED = 'jdkFile';
|
||||||
const INPUT_CHECK_LATEST = 'check-latest';
|
const INPUT_CHECK_LATEST = 'check-latest';
|
||||||
const INPUT_SET_DEFAULT = 'set-default';
|
const INPUT_SET_DEFAULT = 'set-default';
|
||||||
const INPUT_VERIFY_SIGNATURE = 'verify-signature';
|
const INPUT_VERIFY_SIGNATURE = 'verify-signature';
|
||||||
@ -95992,8 +95993,10 @@ function getVersionFromFileContent(content, distributionName, versionFile) {
|
|||||||
if (versionFileName == '.tool-versions' && match?.groups?.distribution) {
|
if (versionFileName == '.tool-versions' && match?.groups?.distribution) {
|
||||||
const asdfDist = match.groups.distribution;
|
const asdfDist = match.groups.distribution;
|
||||||
extractedDistribution = mapAsdfDistribution(asdfDist);
|
extractedDistribution = mapAsdfDistribution(asdfDist);
|
||||||
|
if (extractedDistribution) {
|
||||||
core.debug(`Parsed distribution '${extractedDistribution}' from asdf identifier '${asdfDist}'`);
|
core.debug(`Parsed distribution '${extractedDistribution}' from asdf identifier '${asdfDist}'`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
core.debug(`Parsed version '${capturedVersion}' from file '${versionFileName}'`);
|
core.debug(`Parsed version '${capturedVersion}' from file '${versionFileName}'`);
|
||||||
if (!capturedVersion) {
|
if (!capturedVersion) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
15
dist/setup/index.js
vendored
15
dist/setup/index.js
vendored
@ -73279,7 +73279,8 @@ const INPUT_JAVA_VERSION_FILE = 'java-version-file';
|
|||||||
const INPUT_ARCHITECTURE = 'architecture';
|
const INPUT_ARCHITECTURE = 'architecture';
|
||||||
const INPUT_JAVA_PACKAGE = 'java-package';
|
const INPUT_JAVA_PACKAGE = 'java-package';
|
||||||
const INPUT_DISTRIBUTION = 'distribution';
|
const INPUT_DISTRIBUTION = 'distribution';
|
||||||
const INPUT_JDK_FILE = 'jdkFile';
|
const INPUT_JDK_FILE = 'jdk-file';
|
||||||
|
const INPUT_JDK_FILE_DEPRECATED = 'jdkFile';
|
||||||
const INPUT_CHECK_LATEST = 'check-latest';
|
const INPUT_CHECK_LATEST = 'check-latest';
|
||||||
const INPUT_SET_DEFAULT = 'set-default';
|
const INPUT_SET_DEFAULT = 'set-default';
|
||||||
const INPUT_VERIFY_SIGNATURE = 'verify-signature';
|
const INPUT_VERIFY_SIGNATURE = 'verify-signature';
|
||||||
@ -126984,8 +126985,10 @@ function getVersionFromFileContent(content, distributionName, versionFile) {
|
|||||||
if (versionFileName == '.tool-versions' && match?.groups?.distribution) {
|
if (versionFileName == '.tool-versions' && match?.groups?.distribution) {
|
||||||
const asdfDist = match.groups.distribution;
|
const asdfDist = match.groups.distribution;
|
||||||
extractedDistribution = mapAsdfDistribution(asdfDist);
|
extractedDistribution = mapAsdfDistribution(asdfDist);
|
||||||
|
if (extractedDistribution) {
|
||||||
core_debug(`Parsed distribution '${extractedDistribution}' from asdf identifier '${asdfDist}'`);
|
core_debug(`Parsed distribution '${extractedDistribution}' from asdf identifier '${asdfDist}'`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
core_debug(`Parsed version '${capturedVersion}' from file '${versionFileName}'`);
|
core_debug(`Parsed version '${capturedVersion}' from file '${versionFileName}'`);
|
||||||
if (!capturedVersion) {
|
if (!capturedVersion) {
|
||||||
return null;
|
return null;
|
||||||
@ -133558,7 +133561,7 @@ async function run() {
|
|||||||
const versionFile = getInput(INPUT_JAVA_VERSION_FILE);
|
const versionFile = getInput(INPUT_JAVA_VERSION_FILE);
|
||||||
const architecture = getInput(INPUT_ARCHITECTURE);
|
const architecture = getInput(INPUT_ARCHITECTURE);
|
||||||
const packageType = getInput(INPUT_JAVA_PACKAGE);
|
const packageType = getInput(INPUT_JAVA_PACKAGE);
|
||||||
const jdkFile = getInput(INPUT_JDK_FILE);
|
const jdkFile = getJdkFileInput();
|
||||||
const cache = getInput(INPUT_CACHE);
|
const cache = getInput(INPUT_CACHE);
|
||||||
const cacheDependencyPath = getInput(INPUT_CACHE_DEPENDENCY_PATH);
|
const cacheDependencyPath = getInput(INPUT_CACHE_DEPENDENCY_PATH);
|
||||||
const checkLatest = util_getBooleanInput(INPUT_CHECK_LATEST, false);
|
const checkLatest = util_getBooleanInput(INPUT_CHECK_LATEST, false);
|
||||||
@ -133636,6 +133639,14 @@ async function run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
run();
|
run();
|
||||||
|
function getJdkFileInput() {
|
||||||
|
const jdkFile = getInput(INPUT_JDK_FILE);
|
||||||
|
const deprecatedJdkFile = getInput(INPUT_JDK_FILE_DEPRECATED);
|
||||||
|
if (deprecatedJdkFile) {
|
||||||
|
warning(`The '${INPUT_JDK_FILE_DEPRECATED}' input is deprecated and may be removed in a future release. Please use '${INPUT_JDK_FILE}' instead.`);
|
||||||
|
}
|
||||||
|
return jdkFile || deprecatedJdkFile;
|
||||||
|
}
|
||||||
async function installVersion(version, options, toolchainId = 0) {
|
async function installVersion(version, options, toolchainId = 0) {
|
||||||
const { distributionName, jdkFile, architecture, packageType, checkLatest, setDefault, verifySignature, verifySignaturePublicKey, toolchainIds } = options;
|
const { distributionName, jdkFile, architecture, packageType, checkLatest, setDefault, verifySignature, verifySignaturePublicKey, toolchainIds } = options;
|
||||||
const installerOptions = {
|
const installerOptions = {
|
||||||
|
|||||||
@ -330,7 +330,7 @@ In this example, `JAVA_HOME` and `java` on `PATH` point to Java 17, while Java 2
|
|||||||
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:
|
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:
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> This approach also lets you use builds that setup-java does not provide directly, such as **Early Access (EA)** or other unreleased JDK builds (for example, an upcoming feature release or a Loom/Valhalla preview build). Download the desired archive in a prior step and point `jdkFile` at it; setup-java will extract, install, and cache it just like a supported distribution. When targeting multiple architectures, select the correct binary per architecture in your workflow (for example, with a build matrix).
|
> This approach also lets you use builds that setup-java does not provide directly, such as **Early Access (EA)** or other unreleased JDK builds (for example, an upcoming feature release or a Loom/Valhalla preview build). Download the desired archive in a prior step and point `jdk-file` at it; setup-java will extract, install, and cache it just like a supported distribution. When targeting multiple architectures, select the correct binary per architecture in your workflow (for example, with a build matrix).
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
@ -340,7 +340,7 @@ steps:
|
|||||||
- uses: actions/setup-java@v5
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: 'jdkfile'
|
distribution: 'jdkfile'
|
||||||
jdkFile: ${{ runner.temp }}/java_package.tar.gz
|
jdk-file: ${{ runner.temp }}/java_package.tar.gz
|
||||||
java-version: '11.0.0'
|
java-version: '11.0.0'
|
||||||
architecture: x64
|
architecture: x64
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ steps:
|
|||||||
- uses: actions/setup-java@v5
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: 'jdkfile'
|
distribution: 'jdkfile'
|
||||||
jdkFile: ${{ runner.temp }}/java_package.tar.gz
|
jdk-file: ${{ runner.temp }}/java_package.tar.gz
|
||||||
java-version: '25.0.0-ea.36'
|
java-version: '25.0.0-ea.36'
|
||||||
architecture: x64
|
architecture: x64
|
||||||
|
|
||||||
@ -383,7 +383,7 @@ If your use-case requires a custom distribution (in the example, alpine-linux is
|
|||||||
- uses: actions/setup-java@v5
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: 'jdkfile'
|
distribution: 'jdkfile'
|
||||||
jdkFile: ${{ runner.temp }}/java_package.tar.gz
|
jdk-file: ${{ runner.temp }}/java_package.tar.gz
|
||||||
java-version: {{ steps.fetch_latest_jdk.outputs.java_version }}
|
java-version: {{ steps.fetch_latest_jdk.outputs.java_version }}
|
||||||
architecture: x64
|
architecture: x64
|
||||||
- run: java --version
|
- run: java --version
|
||||||
@ -708,7 +708,7 @@ The result is a Toolchain with entries for JDKs 8, 11 and 15. You can even combi
|
|||||||
- uses: actions/setup-java@v5
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: 'jdkfile'
|
distribution: 'jdkfile'
|
||||||
jdkFile: ${{ runner.temp }}/java_package.tar.gz
|
jdk-file: ${{ runner.temp }}/java_package.tar.gz
|
||||||
java-version: '1.6'
|
java-version: '1.6'
|
||||||
architecture: x64
|
architecture: x64
|
||||||
```
|
```
|
||||||
@ -725,7 +725,7 @@ Each JDK provider will receive a default `vendor` using the `distribution` input
|
|||||||
- uses: actions/setup-java@v5
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: 'jdkfile'
|
distribution: 'jdkfile'
|
||||||
jdkFile: ${{ runner.temp }}/java_package.tar.gz
|
jdk-file: ${{ runner.temp }}/java_package.tar.gz
|
||||||
java-version: '1.6'
|
java-version: '1.6'
|
||||||
architecture: x64
|
architecture: x64
|
||||||
mvn-toolchain-vendor: 'Oracle'
|
mvn-toolchain-vendor: 'Oracle'
|
||||||
|
|||||||
@ -4,7 +4,8 @@ export const INPUT_JAVA_VERSION_FILE = 'java-version-file';
|
|||||||
export const INPUT_ARCHITECTURE = 'architecture';
|
export const INPUT_ARCHITECTURE = 'architecture';
|
||||||
export const INPUT_JAVA_PACKAGE = 'java-package';
|
export const INPUT_JAVA_PACKAGE = 'java-package';
|
||||||
export const INPUT_DISTRIBUTION = 'distribution';
|
export const INPUT_DISTRIBUTION = 'distribution';
|
||||||
export const INPUT_JDK_FILE = 'jdkFile';
|
export const INPUT_JDK_FILE = 'jdk-file';
|
||||||
|
export const INPUT_JDK_FILE_DEPRECATED = 'jdkFile';
|
||||||
export const INPUT_CHECK_LATEST = 'check-latest';
|
export const INPUT_CHECK_LATEST = 'check-latest';
|
||||||
export const INPUT_SET_DEFAULT = 'set-default';
|
export const INPUT_SET_DEFAULT = 'set-default';
|
||||||
export const INPUT_VERIFY_SIGNATURE = 'verify-signature';
|
export const INPUT_VERIFY_SIGNATURE = 'verify-signature';
|
||||||
|
|||||||
@ -22,7 +22,7 @@ async function run() {
|
|||||||
const versionFile = core.getInput(constants.INPUT_JAVA_VERSION_FILE);
|
const versionFile = core.getInput(constants.INPUT_JAVA_VERSION_FILE);
|
||||||
const architecture = core.getInput(constants.INPUT_ARCHITECTURE);
|
const architecture = core.getInput(constants.INPUT_ARCHITECTURE);
|
||||||
const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
|
const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
|
||||||
const jdkFile = core.getInput(constants.INPUT_JDK_FILE);
|
const jdkFile = getJdkFileInput();
|
||||||
const cache = core.getInput(constants.INPUT_CACHE);
|
const cache = core.getInput(constants.INPUT_CACHE);
|
||||||
const cacheDependencyPath = core.getInput(
|
const cacheDependencyPath = core.getInput(
|
||||||
constants.INPUT_CACHE_DEPENDENCY_PATH
|
constants.INPUT_CACHE_DEPENDENCY_PATH
|
||||||
@ -134,6 +134,19 @@ async function run() {
|
|||||||
|
|
||||||
run();
|
run();
|
||||||
|
|
||||||
|
function getJdkFileInput(): string {
|
||||||
|
const jdkFile = core.getInput(constants.INPUT_JDK_FILE);
|
||||||
|
const deprecatedJdkFile = core.getInput(constants.INPUT_JDK_FILE_DEPRECATED);
|
||||||
|
|
||||||
|
if (deprecatedJdkFile) {
|
||||||
|
core.warning(
|
||||||
|
`The '${constants.INPUT_JDK_FILE_DEPRECATED}' input is deprecated and may be removed in a future release. Please use '${constants.INPUT_JDK_FILE}' instead.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return jdkFile || deprecatedJdkFile;
|
||||||
|
}
|
||||||
|
|
||||||
async function installVersion(
|
async function installVersion(
|
||||||
version: string,
|
version: string,
|
||||||
options: installerInputsOptions,
|
options: installerInputsOptions,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user