mirror of
https://github.com/actions/setup-java.git
synced 2026-06-23 00:01:14 +03:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a263f84254 | |||
| 6929a11922 | |||
| ad52b8c6db | |||
| 2321ab295d | |||
| 849c8f0094 |
+1
-13
@@ -9,18 +9,6 @@
|
|||||||
"message": 3
|
"message": 3
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"owner": "javac",
|
|
||||||
"pattern": [
|
|
||||||
{
|
|
||||||
"regexp": "^([^:]+):(\\d+): (warning|error): (.+?)$",
|
|
||||||
"file": 1,
|
|
||||||
"line": 2,
|
|
||||||
"severity": 3,
|
|
||||||
"message": 4
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: undici
|
name: undici
|
||||||
version: 6.27.0
|
version: 6.24.1
|
||||||
type: npm
|
type: npm
|
||||||
summary: An HTTP/1.1 client, written from scratch for Node.js
|
summary: An HTTP/1.1 client, written from scratch for Node.js
|
||||||
homepage: https://undici.nodejs.org
|
homepage: https://undici.nodejs.org
|
||||||
|
|||||||
@@ -25,6 +25,13 @@ This action allows you to work with Java and Scala projects.
|
|||||||
|
|
||||||
For more details, see the full release notes on the [releases page](https://github.com/actions/setup-java/releases/tag/v5.0.0)
|
For more details, see the full release notes on the [releases page](https://github.com/actions/setup-java/releases/tag/v5.0.0)
|
||||||
|
|
||||||
|
## V2 vs V1
|
||||||
|
|
||||||
|
- 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.
|
||||||
|
|
||||||
|
For information about the latest releases, recent updates, and newly supported distributions, please refer to the `setup-java` [Releases](https://github.com/actions/setup-java/releases).
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
- `java-version`: The Java version that is going to be set up. Takes a whole or [semver](#supported-version-syntax) Java version. If not specified, the action will expect `java-version-file` input to be specified.
|
- `java-version`: The Java version that is going to be set up. Takes a whole or [semver](#supported-version-syntax) Java version. If not specified, the action will expect `java-version-file` input to be specified.
|
||||||
@@ -91,8 +98,8 @@ steps:
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### Supported version syntax
|
#### Supported version syntax
|
||||||
The `java-version` input supports an exact version or a version range using [SemVer](https://semver.org/) notation. The values below are examples, not an exhaustive list:
|
The `java-version` input supports an exact version or a version range using [SemVer](https://semver.org/) notation:
|
||||||
- major versions, such as: `8`, `11`, `16`, `17`, `21`, `25`
|
- major versions: `8`, `11`, `16`, `17`, `21`, `25`
|
||||||
- more specific versions: `8.0.282+8`, `8.0.232`, `11.0`, `11.0.4`, `17.0`
|
- more specific versions: `8.0.282+8`, `8.0.232`, `11.0`, `11.0.4`, `17.0`
|
||||||
- early access (EA) versions: `15-ea`, `15.0.0-ea`
|
- early access (EA) versions: `15-ea`, `15.0.0-ea`
|
||||||
|
|
||||||
@@ -112,6 +119,7 @@ Currently, the following distributions are supported:
|
|||||||
| `dragonwell` | [Alibaba Dragonwell JDK](https://dragonwell-jdk.io/) | [`dragonwell` license](https://www.aliyun.com/product/dragonwell/)
|
| `dragonwell` | [Alibaba Dragonwell JDK](https://dragonwell-jdk.io/) | [`dragonwell` license](https://www.aliyun.com/product/dragonwell/)
|
||||||
| `sapmachine` | [SAP SapMachine JDK/JRE](https://sapmachine.io/) | [`sapmachine` license](https://github.com/SAP/SapMachine/blob/sapmachine/LICENSE)
|
| `sapmachine` | [SAP SapMachine JDK/JRE](https://sapmachine.io/) | [`sapmachine` license](https://github.com/SAP/SapMachine/blob/sapmachine/LICENSE)
|
||||||
| `graalvm` | [Oracle GraalVM](https://www.graalvm.org/) | [`graalvm` license](https://www.oracle.com/downloads/licenses/graal-free-license.html)
|
| `graalvm` | [Oracle GraalVM](https://www.graalvm.org/) | [`graalvm` license](https://www.oracle.com/downloads/licenses/graal-free-license.html)
|
||||||
|
| `graalvm-community` | [GraalVM Community](https://github.com/graalvm/graalvm-ce-builds/releases) | [`graalvm-community` license](https://github.com/oracle/graal/blob/master/LICENSE)
|
||||||
| `jetbrains` | [JetBrains Runtime](https://github.com/JetBrains/JetBrainsRuntime/) | [`jetbrains` license](https://github.com/JetBrains/JetBrainsRuntime/blob/main/LICENSE)
|
| `jetbrains` | [JetBrains Runtime](https://github.com/JetBrains/JetBrainsRuntime/) | [`jetbrains` license](https://github.com/JetBrains/JetBrainsRuntime/blob/main/LICENSE)
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
@@ -119,6 +127,7 @@ Currently, the following distributions are supported:
|
|||||||
> - AdoptOpenJDK got moved to Eclipse Temurin and won't be updated anymore. It is highly recommended to migrate workflows from `adopt` and `adopt-openj9`, to `temurin` and `semeru` respectively, 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/).
|
> - AdoptOpenJDK got moved to Eclipse Temurin and won't be updated anymore. It is highly recommended to migrate workflows from `adopt` and `adopt-openj9`, to `temurin` and `semeru` respectively, 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/).
|
||||||
> - For Azul Zulu OpenJDK architectures x64 and arm64 are mapped to x86 / arm with proper hw_bitness.
|
> - For Azul Zulu OpenJDK architectures x64 and arm64 are mapped to x86 / arm with proper hw_bitness.
|
||||||
> - To comply with the GraalVM Free Terms and Conditions (GFTC) license, it is recommended to use GraalVM JDK 17 version 17.0.12, as this is the only version of GraalVM JDK 17 available under the GFTC license. Additionally, it is encouraged to consider upgrading to GraalVM JDK 21, which offers the latest features and improvements.
|
> - To comply with the GraalVM Free Terms and Conditions (GFTC) license, it is recommended to use GraalVM JDK 17 version 17.0.12, as this is the only version of GraalVM JDK 17 available under the GFTC license. Additionally, it is encouraged to consider upgrading to GraalVM JDK 21, which offers the latest features and improvements.
|
||||||
|
> - GraalVM Community is available as `distribution: 'graalvm-community'` for stable JDK 17 and later releases published on GitHub.
|
||||||
|
|
||||||
**NOTE:** Oracle JDK 17 licensing varies by patch level. As shown on the [JDK 17 Archive](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) (versions up to 17.0.12 are under the [NFTC](https://www.oracle.com/downloads/licenses/no-fee-license.html) license) and the [JDK 17.0.13+ Archive](https://www.oracle.com/java/technologies/javase/jdk17-0-13-later-archive-downloads.html) (versions 17.0.13 and later are under the [OTN](https://www.oracle.com/downloads/licenses/javase-license1.html) license). To stay on the free NFTC license, use `distribution: 'oracle'` with `java-version: '17.0.12'` (or earlier) instead of the floating `'17'`. Alternatively, upgrade to Oracle JDK 21+, which remains under the NFTC license.
|
**NOTE:** Oracle JDK 17 licensing varies by patch level. As shown on the [JDK 17 Archive](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) (versions up to 17.0.12 are under the [NFTC](https://www.oracle.com/downloads/licenses/no-fee-license.html) license) and the [JDK 17.0.13+ Archive](https://www.oracle.com/java/technologies/javase/jdk17-0-13-later-archive-downloads.html) (versions 17.0.13 and later are under the [OTN](https://www.oracle.com/downloads/licenses/javase-license1.html) license). To stay on the free NFTC license, use `distribution: 'oracle'` with `java-version: '17.0.12'` (or earlier) instead of the floating `'17'`. Alternatively, upgrade to Oracle JDK 21+, which remains under the NFTC license.
|
||||||
|
|
||||||
@@ -285,15 +294,6 @@ In the example above multiple JDKs are installed for the same job. The result af
|
|||||||
- [Modifying Maven Toolchains](docs/advanced-usage.md#Modifying-Maven-Toolchains)
|
- [Modifying Maven Toolchains](docs/advanced-usage.md#Modifying-Maven-Toolchains)
|
||||||
- [Java Version File](docs/advanced-usage.md#Java-version-file)
|
- [Java Version File](docs/advanced-usage.md#Java-version-file)
|
||||||
|
|
||||||
## V2 vs V1
|
|
||||||
|
|
||||||
Examples in this README use `actions/setup-java@v5`, but the main migration note from V1 still applies to all later major versions (`v2`, `v3`, `v4`, and `v5`):
|
|
||||||
|
|
||||||
- Starting with V2, the action supports custom distributions. V1 supports only Azul Zulu OpenJDK.
|
|
||||||
- Starting with V2, you must specify distribution along with the version. V1 defaults to Azul Zulu OpenJDK, so only version input is required. Follow [the migration guide](docs/switching-to-v2.md) to switch from V1 to V2.
|
|
||||||
|
|
||||||
For information about the latest releases, recent updates, and newly supported distributions, please refer to the `setup-java` [Releases](https://github.com/actions/setup-java/releases).
|
|
||||||
|
|
||||||
## Recommended permissions
|
## Recommended permissions
|
||||||
|
|
||||||
When using the `setup-java` action in your GitHub Actions workflow, it is recommended to set the following permissions to ensure proper functionality:
|
When using the `setup-java` action in your GitHub Actions workflow, it is recommended to set the following permissions to ensure proper functionality:
|
||||||
|
|||||||
@@ -3,7 +3,11 @@ import * as tc from '@actions/tool-cache';
|
|||||||
import * as http from '@actions/http-client';
|
import * as http from '@actions/http-client';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {GraalVMDistribution} from '../../src/distributions/graalvm/installer';
|
import {
|
||||||
|
GraalVMCommunityDistribution,
|
||||||
|
GraalVMDistribution
|
||||||
|
} from '../../src/distributions/graalvm/installer';
|
||||||
|
import {getJavaDistribution} from '../../src/distributions/distribution-factory';
|
||||||
import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
||||||
import * as util from '../../src/util';
|
import * as util from '../../src/util';
|
||||||
|
|
||||||
@@ -41,6 +45,7 @@ beforeAll(() => {
|
|||||||
|
|
||||||
describe('GraalVMDistribution', () => {
|
describe('GraalVMDistribution', () => {
|
||||||
let distribution: GraalVMDistribution;
|
let distribution: GraalVMDistribution;
|
||||||
|
let communityDistribution: GraalVMCommunityDistribution;
|
||||||
let mockHttpClient: jest.Mocked<http.HttpClient>;
|
let mockHttpClient: jest.Mocked<http.HttpClient>;
|
||||||
let spyCoreError: jest.SpyInstance;
|
let spyCoreError: jest.SpyInstance;
|
||||||
|
|
||||||
@@ -55,9 +60,11 @@ describe('GraalVMDistribution', () => {
|
|||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
|
|
||||||
distribution = new GraalVMDistribution(defaultOptions);
|
distribution = new GraalVMDistribution(defaultOptions);
|
||||||
|
communityDistribution = new GraalVMCommunityDistribution(defaultOptions);
|
||||||
|
|
||||||
mockHttpClient = new http.HttpClient() as jest.Mocked<http.HttpClient>;
|
mockHttpClient = new http.HttpClient() as jest.Mocked<http.HttpClient>;
|
||||||
(distribution as any).http = mockHttpClient;
|
(distribution as any).http = mockHttpClient;
|
||||||
|
(communityDistribution as any).http = mockHttpClient;
|
||||||
|
|
||||||
(util.getDownloadArchiveExtension as jest.Mock).mockReturnValue('tar.gz');
|
(util.getDownloadArchiveExtension as jest.Mock).mockReturnValue('tar.gz');
|
||||||
|
|
||||||
@@ -242,6 +249,21 @@ describe('GraalVMDistribution', () => {
|
|||||||
path: '/cached/java/path'
|
path: '/cached/java/path'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should use a dedicated toolcache folder for GraalVM Community', async () => {
|
||||||
|
const result = await (communityDistribution as any).downloadTool(javaRelease);
|
||||||
|
|
||||||
|
expect(tc.cacheDir).toHaveBeenCalledWith(
|
||||||
|
path.join('/tmp/extracted', 'graalvm-jdk-17.0.5'),
|
||||||
|
'Java_GraalVM_Community_jdk',
|
||||||
|
'17.0.5',
|
||||||
|
'x64'
|
||||||
|
);
|
||||||
|
expect(result).toEqual({
|
||||||
|
version: '17.0.5',
|
||||||
|
path: '/cached/java/path'
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('findPackageForDownload', () => {
|
describe('findPackageForDownload', () => {
|
||||||
@@ -948,5 +970,104 @@ describe('GraalVMDistribution', () => {
|
|||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('GraalVMCommunityDistribution', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.spyOn(communityDistribution, 'getPlatform').mockReturnValue('linux');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should resolve an exact GraalVM Community version from GitHub releases', async () => {
|
||||||
|
mockHttpClient.getJson.mockResolvedValue({
|
||||||
|
result: [
|
||||||
|
{
|
||||||
|
draft: false,
|
||||||
|
prerelease: false,
|
||||||
|
assets: [
|
||||||
|
{
|
||||||
|
name: 'graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz',
|
||||||
|
browser_download_url:
|
||||||
|
'https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
statusCode: 200,
|
||||||
|
headers: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await (communityDistribution as any).findPackageForDownload(
|
||||||
|
'21.0.2'
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result).toEqual({
|
||||||
|
url: 'https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz',
|
||||||
|
version: '21.0.2'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should resolve the latest GraalVM Community release for a major version', async () => {
|
||||||
|
mockHttpClient.getJson.mockResolvedValue({
|
||||||
|
result: [
|
||||||
|
{
|
||||||
|
draft: false,
|
||||||
|
prerelease: false,
|
||||||
|
assets: [
|
||||||
|
{
|
||||||
|
name: 'graalvm-community-jdk-21.0.1_linux-x64_bin.tar.gz',
|
||||||
|
browser_download_url:
|
||||||
|
'https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.1/graalvm-community-jdk-21.0.1_linux-x64_bin.tar.gz'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
draft: false,
|
||||||
|
prerelease: false,
|
||||||
|
assets: [
|
||||||
|
{
|
||||||
|
name: 'graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz',
|
||||||
|
browser_download_url:
|
||||||
|
'https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
statusCode: 200,
|
||||||
|
headers: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await (communityDistribution as any).findPackageForDownload(
|
||||||
|
'21'
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result).toEqual({
|
||||||
|
url: 'https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz',
|
||||||
|
version: '21.0.2'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reject GraalVM Community early access requests', async () => {
|
||||||
|
(communityDistribution as any).stable = false;
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
(communityDistribution as any).findPackageForDownload('23')
|
||||||
|
).rejects.toThrow('GraalVM Community does not provide early access builds');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('distribution factory', () => {
|
||||||
|
const defaultOptions: JavaInstallerOptions = {
|
||||||
|
version: '17',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
};
|
||||||
|
|
||||||
|
it('should map graalvm-community to the community installer', () => {
|
||||||
|
const community = getJavaDistribution('graalvm-community', defaultOptions);
|
||||||
|
|
||||||
|
expect(community).toBeInstanceOf(GraalVMCommunityDistribution);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Vendored
+129
-24
@@ -78771,6 +78771,7 @@ var JavaDistribution;
|
|||||||
JavaDistribution["Dragonwell"] = "dragonwell";
|
JavaDistribution["Dragonwell"] = "dragonwell";
|
||||||
JavaDistribution["SapMachine"] = "sapmachine";
|
JavaDistribution["SapMachine"] = "sapmachine";
|
||||||
JavaDistribution["GraalVM"] = "graalvm";
|
JavaDistribution["GraalVM"] = "graalvm";
|
||||||
|
JavaDistribution["GraalVMCommunity"] = "graalvm-community";
|
||||||
JavaDistribution["JetBrains"] = "jetbrains";
|
JavaDistribution["JetBrains"] = "jetbrains";
|
||||||
})(JavaDistribution || (JavaDistribution = {}));
|
})(JavaDistribution || (JavaDistribution = {}));
|
||||||
function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
||||||
@@ -78802,6 +78803,8 @@ function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
|||||||
return new installer_11.SapMachineDistribution(installerOptions);
|
return new installer_11.SapMachineDistribution(installerOptions);
|
||||||
case JavaDistribution.GraalVM:
|
case JavaDistribution.GraalVM:
|
||||||
return new installer_12.GraalVMDistribution(installerOptions);
|
return new installer_12.GraalVMDistribution(installerOptions);
|
||||||
|
case JavaDistribution.GraalVMCommunity:
|
||||||
|
return new installer_12.GraalVMCommunityDistribution(installerOptions);
|
||||||
case JavaDistribution.JetBrains:
|
case JavaDistribution.JetBrains:
|
||||||
return new installer_13.JetBrainsDistribution(installerOptions);
|
return new installer_13.JetBrainsDistribution(installerOptions);
|
||||||
default:
|
default:
|
||||||
@@ -79069,23 +79072,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.GraalVMDistribution = void 0;
|
exports.GraalVMCommunityDistribution = exports.GraalVMDistribution = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(37484));
|
const core = __importStar(__nccwpck_require__(37484));
|
||||||
const tc = __importStar(__nccwpck_require__(33472));
|
const tc = __importStar(__nccwpck_require__(33472));
|
||||||
const fs_1 = __importDefault(__nccwpck_require__(79896));
|
const fs_1 = __importDefault(__nccwpck_require__(79896));
|
||||||
const path_1 = __importDefault(__nccwpck_require__(16928));
|
const path_1 = __importDefault(__nccwpck_require__(16928));
|
||||||
|
const semver_1 = __importDefault(__nccwpck_require__(62088));
|
||||||
const base_installer_1 = __nccwpck_require__(79935);
|
const base_installer_1 = __nccwpck_require__(79935);
|
||||||
const http_client_1 = __nccwpck_require__(54844);
|
const http_client_1 = __nccwpck_require__(54844);
|
||||||
const util_1 = __nccwpck_require__(54527);
|
const util_1 = __nccwpck_require__(54527);
|
||||||
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
|
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
|
||||||
const GRAALVM_DOWNLOAD_URL = 'https://www.graalvm.org/downloads/';
|
const GRAALVM_DOWNLOAD_URL = 'https://www.graalvm.org/downloads/';
|
||||||
|
const GRAALVM_COMMUNITY_RELEASES_URL = 'https://api.github.com/repos/graalvm/graalvm-ce-builds/releases?per_page=100';
|
||||||
|
const GRAALVM_COMMUNITY_RELEASES_PAGE_ORIGIN = 'https://api.github.com';
|
||||||
|
const GRAALVM_COMMUNITY_DOWNLOAD_URL = 'https://github.com/graalvm/graalvm-ce-builds/releases';
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
|
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
|
||||||
const GRAALVM_MIN_VERSION = 17;
|
const GRAALVM_MIN_VERSION = 17;
|
||||||
const SUPPORTED_ARCHITECTURES = ['x64', 'aarch64'];
|
const SUPPORTED_ARCHITECTURES = ['x64', 'aarch64'];
|
||||||
class GraalVMDistribution extends base_installer_1.JavaBase {
|
class GraalVMDistribution extends base_installer_1.JavaBase {
|
||||||
constructor(installerOptions) {
|
constructor(installerOptions, distributionName = 'GraalVM') {
|
||||||
super('GraalVM', installerOptions);
|
super(distributionName, installerOptions);
|
||||||
}
|
}
|
||||||
downloadTool(javaRelease) {
|
downloadTool(javaRelease) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
@@ -79119,36 +79126,50 @@ class GraalVMDistribution extends base_installer_1.JavaBase {
|
|||||||
}
|
}
|
||||||
findPackageForDownload(range) {
|
findPackageForDownload(range) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// Add input validation
|
this.validateVersionRange(range);
|
||||||
if (!range || typeof range !== 'string') {
|
const arch = this.getSupportedArchitecture();
|
||||||
throw new Error('Version range is required and must be a string');
|
|
||||||
}
|
|
||||||
const arch = this.distributionArchitecture();
|
|
||||||
if (!SUPPORTED_ARCHITECTURES.includes(arch)) {
|
|
||||||
throw new Error(`Unsupported architecture: ${this.architecture}. Supported architectures are: ${SUPPORTED_ARCHITECTURES.join(', ')}`);
|
|
||||||
}
|
|
||||||
if (!this.stable) {
|
if (!this.stable) {
|
||||||
return this.findEABuildDownloadUrl(`${range}-ea`);
|
return this.findEABuildDownloadUrl(`${range}-ea`);
|
||||||
}
|
}
|
||||||
if (this.packageType !== 'jdk') {
|
const { platform, extension, major } = this.validateStableBuildRequest(range);
|
||||||
throw new Error('GraalVM provides only the `jdk` package type');
|
|
||||||
}
|
|
||||||
const platform = this.getPlatform();
|
|
||||||
const extension = (0, util_1.getDownloadArchiveExtension)();
|
|
||||||
const major = range.includes('.') ? range.split('.')[0] : range;
|
|
||||||
const majorVersion = parseInt(major);
|
|
||||||
if (isNaN(majorVersion)) {
|
|
||||||
throw new Error(`Invalid version format: ${range}`);
|
|
||||||
}
|
|
||||||
if (majorVersion < GRAALVM_MIN_VERSION) {
|
|
||||||
throw new Error(`GraalVM is only supported for JDK ${GRAALVM_MIN_VERSION} and later. Requested version: ${major}`);
|
|
||||||
}
|
|
||||||
const fileUrl = this.constructFileUrl(range, major, platform, arch, extension);
|
const fileUrl = this.constructFileUrl(range, major, platform, arch, extension);
|
||||||
const response = yield this.http.head(fileUrl);
|
const response = yield this.http.head(fileUrl);
|
||||||
this.handleHttpResponse(response, range);
|
this.handleHttpResponse(response, range);
|
||||||
return { url: fileUrl, version: range };
|
return { url: fileUrl, version: range };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
validateVersionRange(range) {
|
||||||
|
if (!range || typeof range !== 'string') {
|
||||||
|
throw new Error('Version range is required and must be a string');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getSupportedArchitecture() {
|
||||||
|
const arch = this.distributionArchitecture();
|
||||||
|
if (!SUPPORTED_ARCHITECTURES.includes(arch)) {
|
||||||
|
throw new Error(`Unsupported architecture: ${this.architecture}. Supported architectures are: ${SUPPORTED_ARCHITECTURES.join(', ')}`);
|
||||||
|
}
|
||||||
|
return arch;
|
||||||
|
}
|
||||||
|
validateStableBuildRequest(range) {
|
||||||
|
if (this.packageType !== 'jdk') {
|
||||||
|
throw new Error(`${this.distribution} provides only the \`jdk\` package type`);
|
||||||
|
}
|
||||||
|
const platform = this.getPlatform();
|
||||||
|
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||||
|
const major = range.includes('.') ? range.split('.')[0] : range;
|
||||||
|
const majorVersion = parseInt(major);
|
||||||
|
if (isNaN(majorVersion)) {
|
||||||
|
throw new Error(`Invalid version format: ${range}`);
|
||||||
|
}
|
||||||
|
if (majorVersion < GRAALVM_MIN_VERSION) {
|
||||||
|
throw new Error(`${this.distribution} is only supported for JDK ${GRAALVM_MIN_VERSION} and later. Requested version: ${major}`);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
platform,
|
||||||
|
major,
|
||||||
|
extension
|
||||||
|
};
|
||||||
|
}
|
||||||
constructFileUrl(range, major, platform, arch, extension) {
|
constructFileUrl(range, major, platform, arch, extension) {
|
||||||
return range.includes('.')
|
return range.includes('.')
|
||||||
? `${GRAALVM_DL_BASE}/${major}/archive/graalvm-jdk-${range}_${platform}-${arch}_bin.${extension}`
|
? `${GRAALVM_DL_BASE}/${major}/archive/graalvm-jdk-${range}_${platform}-${arch}_bin.${extension}`
|
||||||
@@ -79239,6 +79260,90 @@ class GraalVMDistribution extends base_installer_1.JavaBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.GraalVMDistribution = GraalVMDistribution;
|
exports.GraalVMDistribution = GraalVMDistribution;
|
||||||
|
class GraalVMCommunityDistribution extends GraalVMDistribution {
|
||||||
|
constructor(installerOptions) {
|
||||||
|
super(installerOptions, 'GraalVM Community');
|
||||||
|
}
|
||||||
|
get toolcacheFolderName() {
|
||||||
|
return `Java_GraalVM_Community_${this.packageType}`;
|
||||||
|
}
|
||||||
|
findPackageForDownload(range) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
this.validateVersionRange(range);
|
||||||
|
if (!this.stable) {
|
||||||
|
throw new Error('GraalVM Community does not provide early access builds');
|
||||||
|
}
|
||||||
|
const arch = this.getSupportedArchitecture();
|
||||||
|
const { platform, extension } = this.validateStableBuildRequest(range);
|
||||||
|
const availableVersions = yield this.getAvailableVersionsForPlatform(platform, arch, extension);
|
||||||
|
const satisfiedVersion = availableVersions
|
||||||
|
.filter(item => (0, util_1.isVersionSatisfies)(range, item.version))
|
||||||
|
.sort((a, b) => -semver_1.default.compareBuild(a.version, b.version))[0];
|
||||||
|
if (!satisfiedVersion) {
|
||||||
|
const error = this.createVersionNotFoundError(range, availableVersions.map(item => item.version), `Platform: ${platform}`);
|
||||||
|
error.message += `\nPlease check if this version is available at ${GRAALVM_COMMUNITY_DOWNLOAD_URL}.`;
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
return satisfiedVersion;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
getAvailableVersionsForPlatform(platform, arch, extension) {
|
||||||
|
var _a;
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const headers = (0, util_1.getGitHubHttpHeaders)();
|
||||||
|
const availableVersions = new Map();
|
||||||
|
let releasesUrl = GRAALVM_COMMUNITY_RELEASES_URL;
|
||||||
|
let pageCount = 0;
|
||||||
|
while (releasesUrl) {
|
||||||
|
pageCount++;
|
||||||
|
const response = yield this.http.getJson(releasesUrl, headers);
|
||||||
|
const releases = Array.isArray(response.result) ? response.result : [];
|
||||||
|
for (const release of releases) {
|
||||||
|
if (release.draft || release.prerelease) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (const asset of (_a = release.assets) !== null && _a !== void 0 ? _a : []) {
|
||||||
|
const releaseForPlatform = this.toCommunityReleaseForPlatform(asset, platform, arch, extension);
|
||||||
|
if (releaseForPlatform) {
|
||||||
|
availableVersions.set(releaseForPlatform.version, releaseForPlatform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const nextUrl = (0, util_1.getNextPageUrlFromLinkHeader)(response.headers);
|
||||||
|
if (nextUrl &&
|
||||||
|
!(0, util_1.validatePaginationUrl)(nextUrl, GRAALVM_COMMUNITY_RELEASES_PAGE_ORIGIN)) {
|
||||||
|
core.warning(`Ignoring pagination link with unexpected origin: ${nextUrl}`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
releasesUrl = nextUrl;
|
||||||
|
if (releases.length === 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (pageCount >= util_1.MAX_PAGINATION_PAGES) {
|
||||||
|
core.warning(`Reached pagination safeguard limit (${util_1.MAX_PAGINATION_PAGES} pages) while listing GraalVM Community releases.`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [...availableVersions.values()];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
toCommunityReleaseForPlatform(asset, platform, arch, extension) {
|
||||||
|
const match = asset.name.match(/^graalvm-community-jdk-(?<version>\d+(?:\.\d+)+)_(?<platform>linux|macos|windows)-(?<arch>x64|aarch64)_bin\.(?<extension>tar\.gz|zip)$/);
|
||||||
|
if (!(match === null || match === void 0 ? void 0 : match.groups)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (match.groups.platform !== platform ||
|
||||||
|
match.groups.arch !== arch ||
|
||||||
|
match.groups.extension !== extension) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
version: (0, util_1.convertVersionToSemver)(match.groups.version),
|
||||||
|
url: asset.browser_download_url
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.GraalVMCommunityDistribution = GraalVMCommunityDistribution;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
- [Alibaba Dragonwell](#Alibaba-Dragonwell)
|
- [Alibaba Dragonwell](#Alibaba-Dragonwell)
|
||||||
- [SapMachine](#SapMachine)
|
- [SapMachine](#SapMachine)
|
||||||
- [GraalVM](#GraalVM)
|
- [GraalVM](#GraalVM)
|
||||||
|
- [GraalVM Community](#GraalVM-Community)
|
||||||
- [JetBrains](#JetBrains)
|
- [JetBrains](#JetBrains)
|
||||||
- [Installing custom Java package type](#Installing-custom-Java-package-type)
|
- [Installing custom Java package type](#Installing-custom-Java-package-type)
|
||||||
- [Installing custom Java architecture](#Installing-custom-Java-architecture)
|
- [Installing custom Java architecture](#Installing-custom-Java-architecture)
|
||||||
@@ -172,6 +173,21 @@ steps:
|
|||||||
native-image -cp java HelloWorldApp
|
native-image -cp java HelloWorldApp
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### GraalVM Community
|
||||||
|
**NOTE:** GraalVM Community is available for stable JDK 17 and later releases.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-java@v5
|
||||||
|
with:
|
||||||
|
distribution: 'graalvm-community'
|
||||||
|
java-version: '21'
|
||||||
|
- run: |
|
||||||
|
java -cp java HelloWorldApp
|
||||||
|
native-image -cp java HelloWorldApp
|
||||||
|
```
|
||||||
|
|
||||||
### JetBrains
|
### JetBrains
|
||||||
|
|
||||||
**NOTE:** JetBrains is only available for LTS versions on 11 or later (11, 17, 21, etc.).
|
**NOTE:** JetBrains is only available for LTS versions on 11 or later (11, 17, 21, etc.).
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ We have prepared a short guide so that the process of making your contribution i
|
|||||||
|
|
||||||
## How can I contribute...
|
## How can I contribute...
|
||||||
|
|
||||||
* [:green_book: Contribute Documentation](#contribute-documentation)
|
* [Contribute Documentation:green_book:](#contribute-documentation)
|
||||||
|
|
||||||
* [:computer: Contribute Code](#contribute-code)
|
* [Contribute Code :computer:](#contribute-code)
|
||||||
|
|
||||||
* [:pencil: Provide Support on Issues](#provide-support-on-issues)
|
* [Provide Support on Issues:pencil:](#provide-support-on-issues)
|
||||||
|
|
||||||
* [:mag: Review Pull Requests](#review-pull-requests)
|
* [Review Pull Requests:mag:](#review-pull-requests)
|
||||||
|
|
||||||
## Contribute documentation
|
## Contribute documentation
|
||||||
|
|
||||||
@@ -111,4 +111,4 @@ Another great way to contribute is is to review pull request. Please, be extra k
|
|||||||
- Make sure you're familiar with the code or documentation is updated, unless it's a minor change (spellchecking, minor formatting, etc.)
|
- Make sure you're familiar with the code or documentation is updated, unless it's a minor change (spellchecking, minor formatting, etc.)
|
||||||
- Review changes using the GitHub functionality. You can ask a clarifying question, point out an error or suggest an alternative.
|
- Review changes using the GitHub functionality. You can ask a clarifying question, point out an error or suggest an alternative.
|
||||||
> Note: You may ask for minor changes - "nitpicks", but consider whether they are real blockers to merging or not
|
> Note: You may ask for minor changes - "nitpicks", but consider whether they are real blockers to merging or not
|
||||||
- Submit your review, which may include comments, an approval, or a changes request
|
- Submit your review, which may include comments, an approval, or a changes request
|
||||||
Generated
+369
-548
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -46,7 +46,7 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "^8.48.0",
|
"@typescript-eslint/eslint-plugin": "^8.48.0",
|
||||||
"@typescript-eslint/parser": "^8.61.1",
|
"@typescript-eslint/parser": "^8.61.1",
|
||||||
"@vercel/ncc": "^0.44.0",
|
"@vercel/ncc": "^0.44.0",
|
||||||
"eslint": "^10.5.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-jest": "^29.0.1",
|
"eslint-plugin-jest": "^29.0.1",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ import {CorrettoDistribution} from './corretto/installer';
|
|||||||
import {OracleDistribution} from './oracle/installer';
|
import {OracleDistribution} from './oracle/installer';
|
||||||
import {DragonwellDistribution} from './dragonwell/installer';
|
import {DragonwellDistribution} from './dragonwell/installer';
|
||||||
import {SapMachineDistribution} from './sapmachine/installer';
|
import {SapMachineDistribution} from './sapmachine/installer';
|
||||||
import {GraalVMDistribution} from './graalvm/installer';
|
import {
|
||||||
|
GraalVMCommunityDistribution,
|
||||||
|
GraalVMDistribution
|
||||||
|
} from './graalvm/installer';
|
||||||
import {JetBrainsDistribution} from './jetbrains/installer';
|
import {JetBrainsDistribution} from './jetbrains/installer';
|
||||||
|
|
||||||
enum JavaDistribution {
|
enum JavaDistribution {
|
||||||
@@ -29,6 +32,7 @@ enum JavaDistribution {
|
|||||||
Dragonwell = 'dragonwell',
|
Dragonwell = 'dragonwell',
|
||||||
SapMachine = 'sapmachine',
|
SapMachine = 'sapmachine',
|
||||||
GraalVM = 'graalvm',
|
GraalVM = 'graalvm',
|
||||||
|
GraalVMCommunity = 'graalvm-community',
|
||||||
JetBrains = 'jetbrains'
|
JetBrains = 'jetbrains'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +78,8 @@ export function getJavaDistribution(
|
|||||||
return new SapMachineDistribution(installerOptions);
|
return new SapMachineDistribution(installerOptions);
|
||||||
case JavaDistribution.GraalVM:
|
case JavaDistribution.GraalVM:
|
||||||
return new GraalVMDistribution(installerOptions);
|
return new GraalVMDistribution(installerOptions);
|
||||||
|
case JavaDistribution.GraalVMCommunity:
|
||||||
|
return new GraalVMCommunityDistribution(installerOptions);
|
||||||
case JavaDistribution.JetBrains:
|
case JavaDistribution.JetBrains:
|
||||||
return new JetBrainsDistribution(installerOptions);
|
return new JetBrainsDistribution(installerOptions);
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import * as core from '@actions/core';
|
|||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import semver from 'semver';
|
||||||
import {JavaBase} from '../base-installer';
|
import {JavaBase} from '../base-installer';
|
||||||
import {HttpCodes} from '@actions/http-client';
|
import {HttpCodes} from '@actions/http-client';
|
||||||
import {GraalVMEAVersion} from './models';
|
import {GraalVMEAVersion} from './models';
|
||||||
@@ -11,14 +12,24 @@ import {
|
|||||||
JavaInstallerResults
|
JavaInstallerResults
|
||||||
} from '../base-models';
|
} from '../base-models';
|
||||||
import {
|
import {
|
||||||
|
convertVersionToSemver,
|
||||||
extractJdkFile,
|
extractJdkFile,
|
||||||
getDownloadArchiveExtension,
|
getDownloadArchiveExtension,
|
||||||
getGitHubHttpHeaders,
|
getGitHubHttpHeaders,
|
||||||
renameWinArchive
|
getNextPageUrlFromLinkHeader,
|
||||||
|
isVersionSatisfies,
|
||||||
|
MAX_PAGINATION_PAGES,
|
||||||
|
renameWinArchive,
|
||||||
|
validatePaginationUrl
|
||||||
} from '../../util';
|
} from '../../util';
|
||||||
|
|
||||||
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
|
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
|
||||||
const GRAALVM_DOWNLOAD_URL = 'https://www.graalvm.org/downloads/';
|
const GRAALVM_DOWNLOAD_URL = 'https://www.graalvm.org/downloads/';
|
||||||
|
const GRAALVM_COMMUNITY_RELEASES_URL =
|
||||||
|
'https://api.github.com/repos/graalvm/graalvm-ce-builds/releases?per_page=100';
|
||||||
|
const GRAALVM_COMMUNITY_RELEASES_PAGE_ORIGIN = 'https://api.github.com';
|
||||||
|
const GRAALVM_COMMUNITY_DOWNLOAD_URL =
|
||||||
|
'https://github.com/graalvm/graalvm-ce-builds/releases';
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
|
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
|
||||||
const GRAALVM_MIN_VERSION = 17;
|
const GRAALVM_MIN_VERSION = 17;
|
||||||
@@ -26,9 +37,23 @@ const SUPPORTED_ARCHITECTURES = ['x64', 'aarch64'] as const;
|
|||||||
type SupportedArchitecture = (typeof SUPPORTED_ARCHITECTURES)[number];
|
type SupportedArchitecture = (typeof SUPPORTED_ARCHITECTURES)[number];
|
||||||
type OsVersions = 'linux' | 'macos' | 'windows';
|
type OsVersions = 'linux' | 'macos' | 'windows';
|
||||||
|
|
||||||
|
interface GraalVMCommunityAsset {
|
||||||
|
name: string;
|
||||||
|
browser_download_url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GraalVMCommunityRelease {
|
||||||
|
draft: boolean;
|
||||||
|
prerelease: boolean;
|
||||||
|
assets: GraalVMCommunityAsset[];
|
||||||
|
}
|
||||||
|
|
||||||
export class GraalVMDistribution extends JavaBase {
|
export class GraalVMDistribution extends JavaBase {
|
||||||
constructor(installerOptions: JavaInstallerOptions) {
|
constructor(
|
||||||
super('GraalVM', installerOptions);
|
installerOptions: JavaInstallerOptions,
|
||||||
|
distributionName = 'GraalVM'
|
||||||
|
) {
|
||||||
|
super(distributionName, installerOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async downloadTool(
|
protected async downloadTool(
|
||||||
@@ -85,40 +110,14 @@ export class GraalVMDistribution extends JavaBase {
|
|||||||
protected async findPackageForDownload(
|
protected async findPackageForDownload(
|
||||||
range: string
|
range: string
|
||||||
): Promise<JavaDownloadRelease> {
|
): Promise<JavaDownloadRelease> {
|
||||||
// Add input validation
|
this.validateVersionRange(range);
|
||||||
if (!range || typeof range !== 'string') {
|
const arch = this.getSupportedArchitecture();
|
||||||
throw new Error('Version range is required and must be a string');
|
|
||||||
}
|
|
||||||
|
|
||||||
const arch = this.distributionArchitecture();
|
|
||||||
if (!SUPPORTED_ARCHITECTURES.includes(arch as SupportedArchitecture)) {
|
|
||||||
throw new Error(
|
|
||||||
`Unsupported architecture: ${this.architecture}. Supported architectures are: ${SUPPORTED_ARCHITECTURES.join(', ')}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.stable) {
|
if (!this.stable) {
|
||||||
return this.findEABuildDownloadUrl(`${range}-ea`);
|
return this.findEABuildDownloadUrl(`${range}-ea`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.packageType !== 'jdk') {
|
const {platform, extension, major} = this.validateStableBuildRequest(range);
|
||||||
throw new Error('GraalVM provides only the `jdk` package type');
|
|
||||||
}
|
|
||||||
|
|
||||||
const platform = this.getPlatform();
|
|
||||||
const extension = getDownloadArchiveExtension();
|
|
||||||
const major = range.includes('.') ? range.split('.')[0] : range;
|
|
||||||
const majorVersion = parseInt(major);
|
|
||||||
|
|
||||||
if (isNaN(majorVersion)) {
|
|
||||||
throw new Error(`Invalid version format: ${range}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (majorVersion < GRAALVM_MIN_VERSION) {
|
|
||||||
throw new Error(
|
|
||||||
`GraalVM is only supported for JDK ${GRAALVM_MIN_VERSION} and later. Requested version: ${major}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const fileUrl = this.constructFileUrl(
|
const fileUrl = this.constructFileUrl(
|
||||||
range,
|
range,
|
||||||
@@ -134,6 +133,56 @@ export class GraalVMDistribution extends JavaBase {
|
|||||||
return {url: fileUrl, version: range};
|
return {url: fileUrl, version: range};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected validateVersionRange(range: string): void {
|
||||||
|
if (!range || typeof range !== 'string') {
|
||||||
|
throw new Error('Version range is required and must be a string');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getSupportedArchitecture(): SupportedArchitecture {
|
||||||
|
const arch = this.distributionArchitecture();
|
||||||
|
if (!SUPPORTED_ARCHITECTURES.includes(arch as SupportedArchitecture)) {
|
||||||
|
throw new Error(
|
||||||
|
`Unsupported architecture: ${this.architecture}. Supported architectures are: ${SUPPORTED_ARCHITECTURES.join(', ')}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return arch as SupportedArchitecture;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected validateStableBuildRequest(range: string): {
|
||||||
|
platform: OsVersions;
|
||||||
|
extension: string;
|
||||||
|
major: string;
|
||||||
|
} {
|
||||||
|
if (this.packageType !== 'jdk') {
|
||||||
|
throw new Error(
|
||||||
|
`${this.distribution} provides only the \`jdk\` package type`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const platform = this.getPlatform();
|
||||||
|
const extension = getDownloadArchiveExtension();
|
||||||
|
const major = range.includes('.') ? range.split('.')[0] : range;
|
||||||
|
const majorVersion = parseInt(major);
|
||||||
|
|
||||||
|
if (isNaN(majorVersion)) {
|
||||||
|
throw new Error(`Invalid version format: ${range}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (majorVersion < GRAALVM_MIN_VERSION) {
|
||||||
|
throw new Error(
|
||||||
|
`${this.distribution} is only supported for JDK ${GRAALVM_MIN_VERSION} and later. Requested version: ${major}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
platform,
|
||||||
|
major,
|
||||||
|
extension
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private constructFileUrl(
|
private constructFileUrl(
|
||||||
range: string,
|
range: string,
|
||||||
major: string,
|
major: string,
|
||||||
@@ -280,3 +329,143 @@ export class GraalVMDistribution extends JavaBase {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class GraalVMCommunityDistribution extends GraalVMDistribution {
|
||||||
|
constructor(installerOptions: JavaInstallerOptions) {
|
||||||
|
super(installerOptions, 'GraalVM Community');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected get toolcacheFolderName(): string {
|
||||||
|
return `Java_GraalVM_Community_${this.packageType}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async findPackageForDownload(
|
||||||
|
range: string
|
||||||
|
): Promise<JavaDownloadRelease> {
|
||||||
|
this.validateVersionRange(range);
|
||||||
|
|
||||||
|
if (!this.stable) {
|
||||||
|
throw new Error('GraalVM Community does not provide early access builds');
|
||||||
|
}
|
||||||
|
|
||||||
|
const arch = this.getSupportedArchitecture();
|
||||||
|
const {platform, extension} = this.validateStableBuildRequest(range);
|
||||||
|
const availableVersions = await this.getAvailableVersionsForPlatform(
|
||||||
|
platform,
|
||||||
|
arch,
|
||||||
|
extension
|
||||||
|
);
|
||||||
|
|
||||||
|
const satisfiedVersion = availableVersions
|
||||||
|
.filter(item => isVersionSatisfies(range, item.version))
|
||||||
|
.sort((a, b) => -semver.compareBuild(a.version, b.version))[0];
|
||||||
|
|
||||||
|
if (!satisfiedVersion) {
|
||||||
|
const error = this.createVersionNotFoundError(
|
||||||
|
range,
|
||||||
|
availableVersions.map(item => item.version),
|
||||||
|
`Platform: ${platform}`
|
||||||
|
);
|
||||||
|
error.message += `\nPlease check if this version is available at ${GRAALVM_COMMUNITY_DOWNLOAD_URL}.`;
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return satisfiedVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getAvailableVersionsForPlatform(
|
||||||
|
platform: OsVersions,
|
||||||
|
arch: SupportedArchitecture,
|
||||||
|
extension: string
|
||||||
|
): Promise<JavaDownloadRelease[]> {
|
||||||
|
const headers = getGitHubHttpHeaders();
|
||||||
|
const availableVersions = new Map<string, JavaDownloadRelease>();
|
||||||
|
let releasesUrl: string | null = GRAALVM_COMMUNITY_RELEASES_URL;
|
||||||
|
let pageCount = 0;
|
||||||
|
|
||||||
|
while (releasesUrl) {
|
||||||
|
pageCount++;
|
||||||
|
const response = await this.http.getJson<GraalVMCommunityRelease[]>(
|
||||||
|
releasesUrl,
|
||||||
|
headers
|
||||||
|
);
|
||||||
|
|
||||||
|
const releases = Array.isArray(response.result) ? response.result : [];
|
||||||
|
|
||||||
|
for (const release of releases) {
|
||||||
|
if (release.draft || release.prerelease) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const asset of release.assets ?? []) {
|
||||||
|
const releaseForPlatform = this.toCommunityReleaseForPlatform(
|
||||||
|
asset,
|
||||||
|
platform,
|
||||||
|
arch,
|
||||||
|
extension
|
||||||
|
);
|
||||||
|
if (releaseForPlatform) {
|
||||||
|
availableVersions.set(
|
||||||
|
releaseForPlatform.version,
|
||||||
|
releaseForPlatform
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const nextUrl = getNextPageUrlFromLinkHeader(response.headers);
|
||||||
|
if (
|
||||||
|
nextUrl &&
|
||||||
|
!validatePaginationUrl(nextUrl, GRAALVM_COMMUNITY_RELEASES_PAGE_ORIGIN)
|
||||||
|
) {
|
||||||
|
core.warning(
|
||||||
|
`Ignoring pagination link with unexpected origin: ${nextUrl}`
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
releasesUrl = nextUrl;
|
||||||
|
|
||||||
|
if (releases.length === 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pageCount >= MAX_PAGINATION_PAGES) {
|
||||||
|
core.warning(
|
||||||
|
`Reached pagination safeguard limit (${MAX_PAGINATION_PAGES} pages) while listing GraalVM Community releases.`
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [...availableVersions.values()];
|
||||||
|
}
|
||||||
|
|
||||||
|
private toCommunityReleaseForPlatform(
|
||||||
|
asset: GraalVMCommunityAsset,
|
||||||
|
platform: OsVersions,
|
||||||
|
arch: SupportedArchitecture,
|
||||||
|
extension: string
|
||||||
|
): JavaDownloadRelease | null {
|
||||||
|
const match = asset.name.match(
|
||||||
|
/^graalvm-community-jdk-(?<version>\d+(?:\.\d+)+)_(?<platform>linux|macos|windows)-(?<arch>x64|aarch64)_bin\.(?<extension>tar\.gz|zip)$/
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!match?.groups) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
match.groups.platform !== platform ||
|
||||||
|
match.groups.arch !== arch ||
|
||||||
|
match.groups.extension !== extension
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
version: convertVersionToSemver(match.groups.version),
|
||||||
|
url: asset.browser_download_url
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user