Merge branch 'main' into feature/default-to-runner-architecture

This commit is contained in:
Wes Morgan 2022-09-19 08:58:18 -06:00
commit 36a2b1194e
No known key found for this signature in database
GPG Key ID: 5639E4CBFA17DC84
21 changed files with 4283 additions and 3629 deletions

View File

@ -87,6 +87,43 @@ jobs:
run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}" run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
shell: bash shell: bash
setup-java-multiple-jdks:
name: ${{ matrix.distribution }} ${{ matrix.version }} - multiple jdks - ${{ matrix.os }}
needs: setup-java-major-versions
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['temurin', 'zulu', 'liberica']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: setup-java
uses: ./
id: setup-java
with:
distribution: ${{ matrix.distribution }}
java-version: |
11
17
- name: Verify Java env variables
run: |
$versionsArr = "11","17"
foreach ($version in $versionsArr)
{
$envName = "JAVA_HOME_${version}_${env:RUNNER_ARCH}"
$JavaVersionPath = [Environment]::GetEnvironmentVariable($envName)
if (-not (Test-Path "$JavaVersionPath")) {
Write-Host "$envName is not found"
exit 1
}
}
shell: pwsh
- name: Verify Java
run: bash __tests__/verify-java.sh "17" "${{ steps.setup-java.outputs.path }}"
shell: bash
setup-java-ea-versions-zulu: setup-java-ea-versions-zulu:
name: zulu ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }} name: zulu ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }}
needs: setup-java-major-minor-versions needs: setup-java-major-minor-versions

Binary file not shown.

View File

@ -1,10 +1,8 @@
# setup-java # Setup Java
<p align="left"> [![Main workflow](https://github.com/actions/setup-java/actions/workflows/workflow.yml/badge.svg)](https://github.com/actions/setup-java/actions/workflows/workflow.yml)
<a href="https://github.com/actions/setup-java"><img alt="GitHub Actions status" src="https://github.com/actions/setup-java/workflows/Main%20workflow/badge.svg"></a>
</p>
This action provides the following functionality for GitHub Actions runners: The `setup-java` action provides the following functionality for GitHub Actions runners:
- Downloading and setting up a requested version of Java. See [Usage](#Usage) for a list of supported distributions - Downloading and setting up a requested version of Java. See [Usage](#Usage) for a list of supported distributions
- Extracting and caching custom version of Java from a local file - Extracting and caching custom version of Java from a local file
- Configuring runner for publishing using Apache Maven - Configuring runner for publishing using Apache Maven
@ -18,14 +16,17 @@ This action provides the following functionality for GitHub Actions runners:
This action allows you to work with Java and Scala projects. This action allows you to work with Java and Scala projects.
## V2 vs V1 ## V2 vs V1
- V2 supports custom distributions and provides support for Zulu OpenJDK, Eclipse Temurin and Adopt OpenJDK out of the box. V1 supports only Zulu OpenJDK
- V2 requires you to specify distribution along with the version. V1 defaults to Zulu OpenJDK, only version input is required. Follow [the migration guide](docs/switching-to-v2.md) to switch from V1 to V2 - V2 supports custom distributions and provides support for Azul Zulu OpenJDK, Eclipse Temurin and AdoptOpenJDK out of the box. V1 supports only Azul Zulu OpenJDK
- V2 requires you to specify distribution along with the version. V1 defaults to Azul Zulu OpenJDK, only version input is required. Follow [the migration guide](docs/switching-to-v2.md) to switch from V1 to V2
## Usage ## Usage
Inputs `java-version` and `distribution` are mandatory. See [Supported distributions](#supported-distributions) section for a list of available options. Inputs `java-version` and `distribution` are mandatory. See [Supported distributions](#supported-distributions) section for a list of available options.
### Basic ### Basic Configuration
**Eclipse Temurin**
#### Eclipse Temurin
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -33,18 +34,18 @@ steps:
with: with:
distribution: 'temurin' # See 'Supported distributions' for available options distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17' java-version: '17'
- run: java -cp java HelloWorldApp - run: java HelloWorldApp.java
``` ```
**Zulu OpenJDK** #### Azul Zulu OpenJDK
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-java@v3 - uses: actions/setup-java@v3
with: with:
distribution: 'zulu' # See 'Supported distributions' for available options distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '11' java-version: '17'
- run: java -cp java HelloWorldApp - run: java HelloWorldApp.java
``` ```
#### Supported version syntax #### Supported version syntax
@ -58,18 +59,18 @@ Currently, the following distributions are supported:
| Keyword | Distribution | Official site | License | Keyword | Distribution | Official site | License
|-|-|-|-| |-|-|-|-|
| `temurin` | Eclipse Temurin | [Link](https://adoptium.net/) | [Link](https://adoptium.net/about.html) | `temurin` | Eclipse Temurin | [Link](https://adoptium.net/) | [Link](https://adoptium.net/about.html)
| `zulu` | Zulu OpenJDK | [Link](https://www.azul.com/downloads/zulu-community/?package=jdk) | [Link](https://www.azul.com/products/zulu-and-zulu-enterprise/zulu-terms-of-use/) | | `zulu` | Azul Zulu OpenJDK | [Link](https://www.azul.com/downloads/zulu-community/?package=jdk) | [Link](https://www.azul.com/products/zulu-and-zulu-enterprise/zulu-terms-of-use/) |
| `adopt` or `adopt-hotspot` | Adopt OpenJDK Hotspot | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html) | | `adopt` or `adopt-hotspot` | AdoptOpenJDK Hotspot | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html) |
| `adopt-openj9` | Adopt OpenJDK OpenJ9 | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html) | | `adopt-openj9` | AdoptOpenJDK OpenJ9 | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html) |
| `liberica` | Liberica JDK | [Link](https://bell-sw.com/) | [Link](https://bell-sw.com/liberica_eula/) | | `liberica` | Liberica JDK | [Link](https://bell-sw.com/) | [Link](https://bell-sw.com/liberica_eula/) |
| `microsoft` | Microsoft Build of OpenJDK | [Link](https://www.microsoft.com/openjdk) | [Link](https://docs.microsoft.com/java/openjdk/faq) | `microsoft` | Microsoft Build of OpenJDK | [Link](https://www.microsoft.com/openjdk) | [Link](https://docs.microsoft.com/java/openjdk/faq)
| `corretto` | Amazon Corretto Build of OpenJDK | [Link](https://aws.amazon.com/corretto/) | [Link](https://aws.amazon.com/corretto/faqs/) | `corretto` | Amazon Corretto Build of OpenJDK | [Link](https://aws.amazon.com/corretto/) | [Link](https://aws.amazon.com/corretto/faqs/)
**NOTE:** The different distributors can provide discrepant list of available versions / supported configurations. Please refer to the official documentation to see the list of supported versions. **NOTE:** The different distributors can provide discrepant list of available versions / supported configurations. Please refer to the official documentation to see the list of supported versions.
**NOTE:** Adopt OpenJDK got moved to Eclipse Temurin and won't be updated anymore. It is highly recommended to migrate workflows from `adopt` to `temurin` to keep receiving software and security updates. See more details in the [Good-bye AdoptOpenJDK post](https://blog.adoptopenjdk.net/2021/08/goodbye-adoptopenjdk-hello-adoptium/). **NOTE:** AdoptOpenJDK got moved to Eclipse Temurin and won't be updated anymore. It is highly recommended to migrate workflows from `adopt` to `temurin` to keep receiving software and security updates. See more details in the [Good-bye AdoptOpenJDK post](https://blog.adoptopenjdk.net/2021/08/goodbye-adoptopenjdk-hello-adoptium/).
**NOTE:** For Zulu OpenJDK architectures x64 and arm64 are mapped to x86 / arm with proper hw_bitness. **NOTE:** For Azul Zulu OpenJDK architectures x64 and arm64 are mapped to x86 / arm with proper hw_bitness.
### Caching packages dependencies ### Caching packages dependencies
The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under hood for caching dependencies but requires less configuration settings. Supported package managers are gradle, maven and sbt. The format of the used cache key is `setup-java-${{ platform }}-${{ packageManager }}-${{ fileHash }}`, where the hash is based on the following files: The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under hood for caching dependencies but requires less configuration settings. Supported package managers are gradle, maven and sbt. The format of the used cache key is `setup-java-${{ platform }}-${{ packageManager }}-${{ fileHash }}`, where the hash is based on the following files:
@ -88,7 +89,7 @@ steps:
- uses: actions/setup-java@v3 - uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '11' java-version: '17'
cache: 'gradle' cache: 'gradle'
- run: ./gradlew build --no-daemon - run: ./gradlew build --no-daemon
``` ```
@ -100,7 +101,7 @@ steps:
- uses: actions/setup-java@v3 - uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '11' java-version: '17'
cache: 'maven' cache: 'maven'
- name: Build with Maven - name: Build with Maven
run: mvn -B package --file pom.xml run: mvn -B package --file pom.xml
@ -113,13 +114,14 @@ steps:
- uses: actions/setup-java@v3 - uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '11' java-version: '17'
cache: 'sbt' cache: 'sbt'
- name: Build with SBT - name: Build with SBT
run: sbt package run: sbt package
``` ```
### Check latest ### Check latest
In the basic examples above, the `check-latest` flag defaults to `false`. When set to `false`, the action tries to first resolve a version of Java from the local tool cache on the runner. If unable to find a specific version in the cache, the action will download a version of Java. Use the default or set `check-latest` to `false` if you prefer a faster more consistent setup experience that prioritizes trying to use the cached versions at the expense of newer versions sometimes being available for download. In the basic examples above, the `check-latest` flag defaults to `false`. When set to `false`, the action tries to first resolve a version of Java from the local tool cache on the runner. If unable to find a specific version in the cache, the action will download a version of Java. Use the default or set `check-latest` to `false` if you prefer a faster more consistent setup experience that prioritizes trying to use the cached versions at the expense of newer versions sometimes being available for download.
If `check-latest` is set to `true`, the action first checks if the cached version is the latest one. If the locally cached version is not the most up-to-date, the latest version of Java will be downloaded. Set `check-latest` to `true` if you want the most up-to-date version of Java to always be used. Setting `check-latest` to `true` has performance implications as downloading versions of Java is slower than using cached versions. If `check-latest` is set to `true`, the action first checks if the cached version is the latest one. If the locally cached version is not the most up-to-date, the latest version of Java will be downloaded. Set `check-latest` to `true` if you want the most up-to-date version of Java to always be used. Setting `check-latest` to `true` has performance implications as downloading versions of Java is slower than using cached versions.
@ -133,9 +135,9 @@ steps:
- uses: actions/setup-java@v3 - uses: actions/setup-java@v3
with: with:
distribution: 'adopt' distribution: 'adopt'
java-version: '11' java-version: '17'
check-latest: true check-latest: true
- run: java -cp java HelloWorldApp - run: java HelloWorldApp.java
``` ```
### Testing against different Java versions ### Testing against different Java versions
@ -145,7 +147,7 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy: strategy:
matrix: matrix:
java: [ '8', '11', '13', '15' ] java: [ '8', '11', '17' ]
name: Java ${{ matrix.Java }} sample name: Java ${{ matrix.Java }} sample
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -154,32 +156,25 @@ jobs:
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: ${{ matrix.java }} java-version: ${{ matrix.java }}
- run: java -cp java HelloWorldApp - run: java HelloWorldApp.java
``` ```
### Install multiple JDKs ### Install multiple JDKs
All versions are added to the PATH. The last version will be used and available globally. Other Java versions can be accessed through env variables with such specification as 'JAVA_HOME_{{ MAJOR_VERSION }}_{{ ARCHITECTURE }}'.
```yaml ```yaml
steps: steps:
- uses: actions/setup-java@v3 - uses: actions/setup-java@v3
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: 8 java-version: |
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV 8
11
- uses: actions/setup-java@v3 15
with:
distribution: '<distribution>'
java-version: 11
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV
- uses: actions/setup-java@v3
with:
distribution: '<distribution>'
java-version: 15
- run: echo "JAVA_15=$JAVA_HOME" >> $GITHUB_ENV
``` ```
### Advanced ### Advanced Configuration
- [Selecting a Java distribution](docs/advanced-usage.md#Selecting-a-Java-distribution) - [Selecting a Java distribution](docs/advanced-usage.md#Selecting-a-Java-distribution)
- [Eclipse Temurin](docs/advanced-usage.md#Eclipse-Temurin) - [Eclipse Temurin](docs/advanced-usage.md#Eclipse-Temurin)
- [Adopt](docs/advanced-usage.md#Adopt) - [Adopt](docs/advanced-usage.md#Adopt)

View File

@ -26,7 +26,7 @@ describe('cleanup', () => {
resetState(); resetState();
}); });
it('does not fail nor warn even when the save provess throws a ReserveCacheError', async () => { it('does not fail nor warn even when the save process throws a ReserveCacheError', async () => {
spyCacheSave.mockImplementation((paths: string[], key: string) => spyCacheSave.mockImplementation((paths: string[], key: string) =>
Promise.reject( Promise.reject(
new cache.ReserveCacheError( new cache.ReserveCacheError(

View File

@ -256,6 +256,10 @@ describe('setupJava', () => {
expect(spyGetToolcachePath).toHaveBeenCalled(); expect(spyGetToolcachePath).toHaveBeenCalled();
expect(spyCoreAddPath).toHaveBeenCalled(); expect(spyCoreAddPath).toHaveBeenCalled();
expect(spyCoreExportVariable).toHaveBeenCalled(); expect(spyCoreExportVariable).toHaveBeenCalled();
expect(spyCoreExportVariable).toHaveBeenCalledWith(
`JAVA_HOME_${input.version}_${input.architecture.toLocaleUpperCase()}`,
expected.path
);
expect(spyCoreSetOutput).toHaveBeenCalled(); expect(spyCoreSetOutput).toHaveBeenCalled();
expect(spyCoreInfo).toHaveBeenCalledWith('Trying to resolve the latest version from remote'); expect(spyCoreInfo).toHaveBeenCalledWith('Trying to resolve the latest version from remote');
expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved latest version as ${expected.version}`); expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved latest version as ${expected.version}`);

View File

@ -144,8 +144,8 @@ describe('getAvailableVersions', () => {
}); });
}); });
const mockPlatform = (distributon: CorrettoDistribution, platform: string) => { const mockPlatform = (distribution: CorrettoDistribution, platform: string) => {
distributon['getPlatformOption'] = () => platform; distribution['getPlatformOption'] = () => platform;
const mockedExtension = platform === 'windows' ? 'zip' : 'tar.gz'; const mockedExtension = platform === 'windows' ? 'zip' : 'tar.gz';
spyGetDownloadArchiveExtension.mockReturnValue(mockedExtension); spyGetDownloadArchiveExtension.mockReturnValue(mockedExtension);
}; };

View File

@ -110,7 +110,7 @@ describe('findPackageForDownload', () => {
['15', '15.0.2+7'], ['15', '15.0.2+7'],
['9.0.0', '9.0.0+0'], ['9.0.0', '9.0.0+0'],
['9.0', '9.0.1+0'], ['9.0', '9.0.1+0'],
['8.0.262', '8.0.262+19'], // validate correct choise between [8.0.262.17, 8.0.262.19, 8.0.262.18] ['8.0.262', '8.0.262+19'], // validate correct choice between [8.0.262.17, 8.0.262.19, 8.0.262.18]
['8.0.262+17', '8.0.262+17'], ['8.0.262+17', '8.0.262+17'],
['15.0.1+8', '15.0.1+8'], ['15.0.1+8', '15.0.1+8'],
['15.0.1+9', '15.0.1+9'] ['15.0.1+9', '15.0.1+9']

View File

@ -66,6 +66,8 @@ outputs:
description: 'Actual version of the java environment that has been installed' description: 'Actual version of the java environment that has been installed'
path: path:
description: 'Path to where the java environment has been installed (same as $JAVA_HOME)' description: 'Path to where the java environment has been installed (same as $JAVA_HOME)'
cache-hit:
description: 'A boolean value to indicate an exact match was found for the primary key'
runs: runs:
using: 'node16' using: 'node16'
main: 'dist/setup/index.js' main: 'dist/setup/index.js'

2047
dist/cleanup/index.js vendored

File diff suppressed because it is too large Load Diff

2125
dist/setup/index.js vendored

File diff suppressed because it is too large Load Diff

3509
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "setup-java", "name": "setup-java",
"version": "3.1.1", "version": "3.4.1",
"private": true, "private": true,
"description": "setup java action", "description": "setup java action",
"main": "dist/setup/index.js", "main": "dist/setup/index.js",
@ -25,7 +25,7 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^3.0.0", "@actions/cache": "^3.0.0",
"@actions/core": "^1.2.6", "@actions/core": "^1.9.0",
"@actions/exec": "^1.0.4", "@actions/exec": "^1.0.4",
"@actions/glob": "^0.2.0", "@actions/glob": "^0.2.0",
"@actions/http-client": "^1.0.11", "@actions/http-client": "^1.0.11",
@ -38,9 +38,9 @@
"@types/jest": "^27.0.2", "@types/jest": "^27.0.2",
"@types/node": "^16.11.25", "@types/node": "^16.11.25",
"@types/semver": "^7.3.4", "@types/semver": "^7.3.4",
"@vercel/ncc": "^0.33.4",
"jest": "^27.2.5", "jest": "^27.2.5",
"jest-circus": "^27.2.5", "jest-circus": "^27.2.5",
"@vercel/ncc": "^0.33.4",
"prettier": "^1.19.1", "prettier": "^1.19.1",
"ts-jest": "^27.0.5", "ts-jest": "^27.0.5",
"typescript": "^4.2.3" "typescript": "^4.2.3"

View File

@ -116,7 +116,7 @@ export async function save(id: string) {
const packageManager = findPackageManager(id); const packageManager = findPackageManager(id);
const matchedKey = core.getState(CACHE_MATCHED_KEY); const matchedKey = core.getState(CACHE_MATCHED_KEY);
// Inputs are re-evaluted before the post action, so we want the original key used for restore // Inputs are re-evaluated before the post action, so we want the original key used for restore
const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY); const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY);
if (!primaryKey) { if (!primaryKey) {

View File

@ -93,7 +93,9 @@ export class AdoptDistribution extends JavaBase {
const versionRange = encodeURI('[1.0,100.0]'); // retrieve all available versions const versionRange = encodeURI('[1.0,100.0]'); // retrieve all available versions
const releaseType = this.stable ? 'ga' : 'ea'; const releaseType = this.stable ? 'ga' : 'ea';
console.time('adopt-retrieve-available-versions'); if (core.isDebug()) {
console.time('adopt-retrieve-available-versions');
}
const baseRequestArguments = [ const baseRequestArguments = [
`project=jdk`, `project=jdk`,

View File

@ -143,11 +143,13 @@ export abstract class JavaBase {
} }
protected setJavaDefault(version: string, toolPath: string) { protected setJavaDefault(version: string, toolPath: string) {
const majorVersion = version.split('.')[0];
core.exportVariable('JAVA_HOME', toolPath); core.exportVariable('JAVA_HOME', toolPath);
core.addPath(path.join(toolPath, 'bin')); core.addPath(path.join(toolPath, 'bin'));
core.setOutput('distribution', this.distribution); core.setOutput('distribution', this.distribution);
core.setOutput('path', toolPath); core.setOutput('path', toolPath);
core.setOutput('version', version); core.setOutput('version', version);
core.exportVariable(`JAVA_HOME_${majorVersion}_${this.architecture.toUpperCase()}`, toolPath);
} }
protected distributionArchitecture(): string { protected distributionArchitecture(): string {

View File

@ -5,7 +5,7 @@ import path from 'path';
import { extractJdkFile, getDownloadArchiveExtension } from '../../util'; import { extractJdkFile, getDownloadArchiveExtension } from '../../util';
import { JavaBase } from '../base-installer'; import { JavaBase } from '../base-installer';
import { JavaDownloadRelease, JavaInstallerOptions, JavaInstallerResults } from '../base-models'; import { JavaDownloadRelease, JavaInstallerOptions, JavaInstallerResults } from '../base-models';
import { ICorrettoAllAvailableVersions, ICorettoAvailableVersions } from './models'; import { ICorrettoAllAvailableVersions, ICorrettoAvailableVersions } from './models';
export class CorrettoDistribution extends JavaBase { export class CorrettoDistribution extends JavaBase {
constructor(installerOptions: JavaInstallerOptions) { constructor(installerOptions: JavaInstallerOptions) {
@ -66,12 +66,14 @@ export class CorrettoDistribution extends JavaBase {
return resolvedVersion; return resolvedVersion;
} }
private async getAvailableVersions(): Promise<ICorettoAvailableVersions[]> { private async getAvailableVersions(): Promise<ICorrettoAvailableVersions[]> {
const platform = this.getPlatformOption(); const platform = this.getPlatformOption();
const arch = this.distributionArchitecture(); const arch = this.distributionArchitecture();
const imageType = this.packageType; const imageType = this.packageType;
console.time('coretto-retrieve-available-versions'); if (core.isDebug()) {
console.time('corretto-retrieve-available-versions');
}
const availableVersionsUrl = const availableVersionsUrl =
'https://corretto.github.io/corretto-downloads/latest_links/indexmap_with_checksum.json'; 'https://corretto.github.io/corretto-downloads/latest_links/indexmap_with_checksum.json';
@ -83,8 +85,8 @@ export class CorrettoDistribution extends JavaBase {
throw Error(`Could not fetch latest corretto versions from ${availableVersionsUrl}`); throw Error(`Could not fetch latest corretto versions from ${availableVersionsUrl}`);
} }
const eligbleVersions = fetchedCurrentVersions?.[platform]?.[arch]?.[imageType]; const eligibleVersions = fetchedCurrentVersions?.[platform]?.[arch]?.[imageType];
const availableVersions = this.getAvailableVersionsForPlatform(eligbleVersions); const availableVersions = this.getAvailableVersionsForPlatform(eligibleVersions);
if (core.isDebug()) { if (core.isDebug()) {
this.printAvailableVersions(availableVersions); this.printAvailableVersions(availableVersions);
@ -94,19 +96,19 @@ export class CorrettoDistribution extends JavaBase {
} }
private getAvailableVersionsForPlatform( private getAvailableVersionsForPlatform(
eligbleVersions: ICorrettoAllAvailableVersions['os']['arch']['imageType'] | undefined eligibleVersions: ICorrettoAllAvailableVersions['os']['arch']['imageType'] | undefined
): ICorettoAvailableVersions[] { ): ICorrettoAvailableVersions[] {
const availableVersions: ICorettoAvailableVersions[] = []; const availableVersions: ICorrettoAvailableVersions[] = [];
for (const version in eligbleVersions) { for (const version in eligibleVersions) {
const availableVersion = eligbleVersions[version]; const availableVersion = eligibleVersions[version];
for (const fileType in availableVersion) { for (const fileType in availableVersion) {
const skipNonExtractableBinaries = fileType != getDownloadArchiveExtension(); const skipNonExtractableBinaries = fileType != getDownloadArchiveExtension();
if (skipNonExtractableBinaries) { if (skipNonExtractableBinaries) {
continue; continue;
} }
const availableVersionDetails = availableVersion[fileType]; const availableVersionDetails = availableVersion[fileType];
const correttoVersion = this.getCorettoVersion(availableVersionDetails.resource); const correttoVersion = this.getCorrettoVersion(availableVersionDetails.resource);
availableVersions.push({ availableVersions.push({
checksum: availableVersionDetails.checksum, checksum: availableVersionDetails.checksum,
@ -122,9 +124,9 @@ export class CorrettoDistribution extends JavaBase {
return availableVersions; return availableVersions;
} }
private printAvailableVersions(availableVersions: ICorettoAvailableVersions[]) { private printAvailableVersions(availableVersions: ICorrettoAvailableVersions[]) {
core.startGroup('Print information about available versions'); core.startGroup('Print information about available versions');
console.timeEnd('coretto-retrieve-available-versions'); console.timeEnd('corretto-retrieve-available-versions');
console.log(`Available versions: [${availableVersions.length}]`); console.log(`Available versions: [${availableVersions.length}]`);
console.log( console.log(
availableVersions.map(item => `${item.version}: ${item.correttoVersion}`).join(', ') availableVersions.map(item => `${item.version}: ${item.correttoVersion}`).join(', ')
@ -133,7 +135,7 @@ export class CorrettoDistribution extends JavaBase {
} }
private getPlatformOption(): string { private getPlatformOption(): string {
// Coretto has its own platform names so we need to map them // Corretto has its own platform names so we need to map them
switch (process.platform) { switch (process.platform) {
case 'darwin': case 'darwin':
return 'macos'; return 'macos';
@ -144,7 +146,7 @@ export class CorrettoDistribution extends JavaBase {
} }
} }
private getCorettoVersion(resource: string): string { private getCorrettoVersion(resource: string): string {
const regex = /(\d+.+)\//; const regex = /(\d+.+)\//;
const match = regex.exec(resource); const match = regex.exec(resource);
if (match === null) { if (match === null) {

View File

@ -14,7 +14,7 @@ export interface ICorrettoAllAvailableVersions {
}; };
} }
export interface ICorettoAvailableVersions { export interface ICorrettoAvailableVersions {
version: string; version: string;
fileType: string; fileType: string;
checksum: string; checksum: string;

View File

@ -66,7 +66,9 @@ export class LibericaDistributions extends JavaBase {
} }
private async getAvailableVersions(): Promise<LibericaVersion[]> { private async getAvailableVersions(): Promise<LibericaVersion[]> {
console.time('liberica-retrieve-available-versions'); if (core.isDebug()) {
console.time('liberica-retrieve-available-versions');
}
const url = this.prepareAvailableVersionsUrl(); const url = this.prepareAvailableVersionsUrl();
if (core.isDebug()) { if (core.isDebug()) {

View File

@ -91,7 +91,9 @@ export class TemurinDistribution extends JavaBase {
const versionRange = encodeURI('[1.0,100.0]'); // retrieve all available versions const versionRange = encodeURI('[1.0,100.0]'); // retrieve all available versions
const releaseType = this.stable ? 'ga' : 'ea'; const releaseType = this.stable ? 'ga' : 'ea';
console.time('temurin-retrieve-available-versions'); if (core.isDebug()) {
console.time('temurin-retrieve-available-versions');
}
const baseRequestArguments = [ const baseRequestArguments = [
`project=jdk`, `project=jdk`,

View File

@ -90,7 +90,9 @@ export class ZuluDistribution extends JavaBase {
const javafx = features?.includes('fx') ?? false; const javafx = features?.includes('fx') ?? false;
const releaseStatus = this.stable ? 'ga' : 'ea'; const releaseStatus = this.stable ? 'ga' : 'ea';
console.time('azul-retrieve-available-versions'); if (core.isDebug()) {
console.time('azul-retrieve-available-versions');
}
const requestArguments = [ const requestArguments = [
`os=${platform}`, `os=${platform}`,
`ext=${extension}`, `ext=${extension}`,

View File

@ -9,7 +9,7 @@ import { JavaInstallerOptions } from './distributions/base-models';
async function run() { async function run() {
try { try {
const version = core.getInput(constants.INPUT_JAVA_VERSION, { required: true }); const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION, { required: true });
const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, { required: true }); const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, { required: true });
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);
@ -17,27 +17,30 @@ async function run() {
const cache = core.getInput(constants.INPUT_CACHE); const cache = core.getInput(constants.INPUT_CACHE);
const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false); const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false);
const installerOptions: JavaInstallerOptions = { core.startGroup('Installed distributions');
architecture, for (const version of versions) {
packageType, const installerOptions: JavaInstallerOptions = {
version, architecture,
checkLatest packageType,
}; version,
checkLatest
};
const distribution = getJavaDistribution(distributionName, installerOptions, jdkFile); const distribution = getJavaDistribution(distributionName, installerOptions, jdkFile);
if (!distribution) { if (!distribution) {
throw new Error(`No supported distribution was found for input ${distributionName}`); throw new Error(`No supported distribution was found for input ${distributionName}`);
}
const result = await distribution.setupJava();
core.info('');
core.info('Java configuration:');
core.info(` Distribution: ${distributionName}`);
core.info(` Version: ${result.version}`);
core.info(` Path: ${result.path}`);
core.info('');
} }
core.endGroup();
const result = await distribution.setupJava();
core.info('');
core.info('Java configuration:');
core.info(` Distribution: ${distributionName}`);
core.info(` Version: ${result.version}`);
core.info(` Path: ${result.path}`);
core.info('');
const matchersPath = path.join(__dirname, '..', '..', '.github'); const matchersPath = path.join(__dirname, '..', '..', '.github');
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`); core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);