mirror of
https://github.com/actions/setup-java.git
synced 2026-06-23 00:09:42 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 47340fb2e8 | |||
| 9525efcdb4 | |||
| 7cec43d3da | |||
| c3b0b6b300 |
@@ -1,22 +0,0 @@
|
||||
---
|
||||
name: New Java distribution template
|
||||
about: Suggest a new Java distribution
|
||||
title: ''
|
||||
labels: feature request, needs triage
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
**Description:**
|
||||
Describe your proposal.
|
||||
|
||||
**Justification:**
|
||||
Justification or a use case for your proposal.
|
||||
|
||||
**Download URL:**
|
||||
Download URL for the new distribution.
|
||||
|
||||
**License:**
|
||||
Link to the license for the new distribution.
|
||||
|
||||
**Are you willing to submit a PR?**
|
||||
<!--- We accept contributions! -->
|
||||
@@ -1,16 +0,0 @@
|
||||
**Description:**
|
||||
Describe your changes.
|
||||
|
||||
**Related issue:**
|
||||
Add link to the related issue.
|
||||
|
||||
**Download URL:**
|
||||
Download URL for the new distribution.
|
||||
|
||||
**License:**
|
||||
Link to the license for the new distribution.
|
||||
|
||||
**Check list:**
|
||||
- [ ] Mark if documentation changes are required.
|
||||
- [ ] Mark if tests were added or updated to cover the changes.
|
||||
- [ ] Mark if new distribution is being added.
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Run setup-java with the cache for gradle
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -51,7 +51,7 @@ jobs:
|
||||
needs: gradle1-save
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Run setup-java with the cache for gradle
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -76,7 +76,7 @@ jobs:
|
||||
needs: gradle1-save
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Run setup-java with the cache for gradle
|
||||
uses: ./
|
||||
id: setup-java
|
||||
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Run setup-java with the cache for gradle
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -50,7 +50,7 @@ jobs:
|
||||
needs: gradle-save
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Run setup-java with the cache for gradle
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -73,7 +73,7 @@ jobs:
|
||||
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Run setup-java with the cache for maven
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -97,7 +97,7 @@ jobs:
|
||||
needs: maven-save
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Run setup-java with the cache for maven
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -124,7 +124,7 @@ jobs:
|
||||
os: [macos-15-intel, windows-latest, ubuntu-22.04]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Run setup-java with the cache for sbt
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -174,7 +174,7 @@ jobs:
|
||||
needs: sbt-save
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Run setup-java with the cache for sbt
|
||||
uses: ./
|
||||
id: setup-java
|
||||
|
||||
@@ -21,7 +21,7 @@ jobs:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Download Adopt OpenJDK file
|
||||
run: |
|
||||
if ($IsLinux) {
|
||||
@@ -58,7 +58,7 @@ jobs:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Download Zulu OpenJDK file
|
||||
run: |
|
||||
if ($IsLinux) {
|
||||
@@ -95,7 +95,7 @@ jobs:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Download Eclipse Temurin file
|
||||
run: |
|
||||
if ($IsLinux) {
|
||||
|
||||
@@ -25,7 +25,7 @@ jobs:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -60,7 +60,7 @@ jobs:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Create fake settings.xml
|
||||
run: |
|
||||
$xmlDirectory = Join-Path $HOME ".m2"
|
||||
@@ -96,7 +96,7 @@ jobs:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Create fake settings.xml
|
||||
run: |
|
||||
$xmlDirectory = Join-Path $HOME ".m2"
|
||||
@@ -133,7 +133,7 @@ jobs:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
|
||||
@@ -73,7 +73,7 @@ jobs:
|
||||
version: '24-ea'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -99,7 +99,7 @@ jobs:
|
||||
version: ['21', '17']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Install bash
|
||||
run: apk add --no-cache bash
|
||||
- name: setup-java
|
||||
@@ -149,7 +149,7 @@ jobs:
|
||||
version: '17.0.7'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -184,7 +184,7 @@ jobs:
|
||||
os: macos-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -220,7 +220,7 @@ jobs:
|
||||
os: macos-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -259,7 +259,7 @@ jobs:
|
||||
version: ['17-ea', '15.0.0-ea.14']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -281,7 +281,7 @@ jobs:
|
||||
version: ['17-ea']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -303,7 +303,7 @@ jobs:
|
||||
version: ['17-ea', '21-ea']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -390,7 +390,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -418,7 +418,7 @@ jobs:
|
||||
version: ['11']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -441,7 +441,7 @@ jobs:
|
||||
java-version-file: ['.java-version', '.tool-versions']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Create .java-version file
|
||||
shell: bash
|
||||
run: echo "17" > .java-version
|
||||
@@ -470,7 +470,7 @@ jobs:
|
||||
java-version-file: ['.java-version', '.tool-versions']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Create .java-version file
|
||||
shell: bash
|
||||
run: echo "11" > .java-version
|
||||
@@ -498,7 +498,7 @@ jobs:
|
||||
java-version-file: ['.java-version', '.tool-versions']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Create .java-version file
|
||||
shell: bash
|
||||
run: echo "17.0.10" > .java-version
|
||||
@@ -526,7 +526,7 @@ jobs:
|
||||
java-version-file: ['.java-version', '.tool-versions', '.sdkmanrc']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Create .java-version file
|
||||
shell: bash
|
||||
run: echo "openjdk64-17.0.10" > .java-version
|
||||
|
||||
@@ -15,7 +15,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checking out
|
||||
uses: actions/checkout@v7
|
||||
uses: actions/checkout@v6
|
||||
- name: Publish
|
||||
id: publish
|
||||
uses: actions/publish-immutable-action@v0.0.4
|
||||
|
||||
@@ -37,7 +37,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.
|
||||
|
||||
- `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.
|
||||
- `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.
|
||||
|
||||
- `check-latest`: Setting this option makes the action to check for the latest available version for the version spec.
|
||||
|
||||
@@ -76,7 +76,7 @@ steps:
|
||||
with:
|
||||
distribution: 'temurin' # See 'Supported distributions' for available options
|
||||
java-version: '25'
|
||||
- run: java --version
|
||||
- run: java HelloWorldApp.java
|
||||
```
|
||||
|
||||
#### Azul Zulu OpenJDK
|
||||
@@ -87,7 +87,7 @@ steps:
|
||||
with:
|
||||
distribution: 'zulu' # See 'Supported distributions' for available options
|
||||
java-version: '25'
|
||||
- run: java --version
|
||||
- run: java HelloWorldApp.java
|
||||
```
|
||||
|
||||
#### Supported version syntax
|
||||
@@ -112,16 +112,13 @@ Currently, the following distributions are supported:
|
||||
| `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)
|
||||
| `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)
|
||||
| `jdkfile` | Custom JDK Installation | |
|
||||
|
||||
> [!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.
|
||||
> - 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.
|
||||
> - 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.
|
||||
|
||||
@@ -131,7 +128,7 @@ Currently, the following distributions are supported:
|
||||
The action has a built-in functionality for caching and restoring dependencies. It uses [toolkit/cache](https://github.com/actions/toolkit/tree/main/packages/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:
|
||||
|
||||
- gradle: `**/*.gradle*`, `**/gradle-wrapper.properties`, `buildSrc/**/Versions.kt`, `buildSrc/**/Dependencies.kt`, `gradle/*.versions.toml`, and `**/versions.properties`
|
||||
- maven: `**/pom.xml` and `**/.mvn/wrapper/maven-wrapper.properties`
|
||||
- maven: `**/pom.xml`, `**/.mvn/wrapper/maven-wrapper.properties`, and `**/.mvn/extensions.xml`
|
||||
- sbt: all sbt build definition files `**/*.sbt`, `**/project/build.properties`, `**/project/**.scala`, `**/project/**.sbt`
|
||||
|
||||
When the option `cache-dependency-path` is specified, the hash is based on the matching file. This option supports wildcards and a list of file names, and is especially useful for monorepos.
|
||||
@@ -223,7 +220,7 @@ steps:
|
||||
distribution: 'temurin'
|
||||
java-version: '25'
|
||||
check-latest: true
|
||||
- run: java --version
|
||||
- run: java HelloWorldApp.java
|
||||
```
|
||||
|
||||
### Testing against different Java versions
|
||||
@@ -242,7 +239,7 @@ jobs:
|
||||
with:
|
||||
distribution: '<distribution>'
|
||||
java-version: ${{ matrix.java }}
|
||||
- run: java --version
|
||||
- run: java HelloWorldApp.java
|
||||
```
|
||||
|
||||
### Install multiple JDKs
|
||||
|
||||
+22
-4
@@ -96,11 +96,11 @@ describe('dependency cache', () => {
|
||||
});
|
||||
|
||||
describe('for maven', () => {
|
||||
it('throws error if no pom.xml or maven-wrapper.properties found', async () => {
|
||||
it('throws error if no pom.xml, maven-wrapper.properties, or extensions.xml found', async () => {
|
||||
await expect(restore('maven', '')).rejects.toThrow(
|
||||
`No file in ${projectRoot(
|
||||
workspace
|
||||
)} matched to [**/pom.xml,**/.mvn/wrapper/maven-wrapper.properties], make sure you have checked out the target repository`
|
||||
)} matched to [**/pom.xml,**/.mvn/wrapper/maven-wrapper.properties,**/.mvn/extensions.xml], make sure you have checked out the target repository`
|
||||
);
|
||||
});
|
||||
it('downloads cache based on pom.xml', async () => {
|
||||
@@ -115,7 +115,7 @@ describe('dependency cache', () => {
|
||||
expect.any(String)
|
||||
);
|
||||
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||
'**/pom.xml\n**/.mvn/wrapper/maven-wrapper.properties'
|
||||
'**/pom.xml\n**/.mvn/wrapper/maven-wrapper.properties\n**/.mvn/extensions.xml'
|
||||
);
|
||||
expect(spyWarning).not.toHaveBeenCalled();
|
||||
expect(spyInfo).toHaveBeenCalledWith('maven cache is not found');
|
||||
@@ -136,7 +136,25 @@ describe('dependency cache', () => {
|
||||
expect.any(String)
|
||||
);
|
||||
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||
'**/pom.xml\n**/.mvn/wrapper/maven-wrapper.properties'
|
||||
'**/pom.xml\n**/.mvn/wrapper/maven-wrapper.properties\n**/.mvn/extensions.xml'
|
||||
);
|
||||
expect(spyWarning).not.toHaveBeenCalled();
|
||||
expect(spyInfo).toHaveBeenCalledWith('maven cache is not found');
|
||||
});
|
||||
it('downloads cache based on extensions.xml', async () => {
|
||||
createDirectory(join(workspace, '.mvn'));
|
||||
createFile(join(workspace, '.mvn', 'extensions.xml'));
|
||||
|
||||
await restore('maven', '');
|
||||
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||
[
|
||||
join(os.homedir(), '.m2', 'repository'),
|
||||
join(os.homedir(), '.m2', 'wrapper', 'dists')
|
||||
],
|
||||
expect.any(String)
|
||||
);
|
||||
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||
'**/pom.xml\n**/.mvn/wrapper/maven-wrapper.properties\n**/.mvn/extensions.xml'
|
||||
);
|
||||
expect(spyWarning).not.toHaveBeenCalled();
|
||||
expect(spyInfo).toHaveBeenCalledWith('maven cache is not found');
|
||||
|
||||
@@ -3,11 +3,7 @@ import * as tc from '@actions/tool-cache';
|
||||
import * as http from '@actions/http-client';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import {
|
||||
GraalVMCommunityDistribution,
|
||||
GraalVMDistribution
|
||||
} from '../../src/distributions/graalvm/installer';
|
||||
import {getJavaDistribution} from '../../src/distributions/distribution-factory';
|
||||
import {GraalVMDistribution} from '../../src/distributions/graalvm/installer';
|
||||
import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
||||
import * as util from '../../src/util';
|
||||
|
||||
@@ -45,7 +41,6 @@ beforeAll(() => {
|
||||
|
||||
describe('GraalVMDistribution', () => {
|
||||
let distribution: GraalVMDistribution;
|
||||
let communityDistribution: GraalVMCommunityDistribution;
|
||||
let mockHttpClient: jest.Mocked<http.HttpClient>;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
@@ -60,11 +55,9 @@ describe('GraalVMDistribution', () => {
|
||||
jest.clearAllMocks();
|
||||
|
||||
distribution = new GraalVMDistribution(defaultOptions);
|
||||
communityDistribution = new GraalVMCommunityDistribution(defaultOptions);
|
||||
|
||||
mockHttpClient = new http.HttpClient() as jest.Mocked<http.HttpClient>;
|
||||
(distribution as any).http = mockHttpClient;
|
||||
(communityDistribution as any).http = mockHttpClient;
|
||||
|
||||
(util.getDownloadArchiveExtension as jest.Mock).mockReturnValue('tar.gz');
|
||||
|
||||
@@ -249,21 +242,6 @@ describe('GraalVMDistribution', () => {
|
||||
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', () => {
|
||||
@@ -970,104 +948,5 @@ describe('GraalVMDistribution', () => {
|
||||
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
+5
-1
@@ -51973,7 +51973,11 @@ const supportedPackageManager = [
|
||||
(0, path_1.join)(os_1.default.homedir(), '.m2', 'wrapper', 'dists')
|
||||
],
|
||||
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven
|
||||
pattern: ['**/pom.xml', '**/.mvn/wrapper/maven-wrapper.properties']
|
||||
pattern: [
|
||||
'**/pom.xml',
|
||||
'**/.mvn/wrapper/maven-wrapper.properties',
|
||||
'**/.mvn/extensions.xml'
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'gradle',
|
||||
|
||||
Vendored
+29
-133
@@ -77837,7 +77837,11 @@ const supportedPackageManager = [
|
||||
(0, path_1.join)(os_1.default.homedir(), '.m2', 'wrapper', 'dists')
|
||||
],
|
||||
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven
|
||||
pattern: ['**/pom.xml', '**/.mvn/wrapper/maven-wrapper.properties']
|
||||
pattern: [
|
||||
'**/pom.xml',
|
||||
'**/.mvn/wrapper/maven-wrapper.properties',
|
||||
'**/.mvn/extensions.xml'
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'gradle',
|
||||
@@ -78771,7 +78775,6 @@ var JavaDistribution;
|
||||
JavaDistribution["Dragonwell"] = "dragonwell";
|
||||
JavaDistribution["SapMachine"] = "sapmachine";
|
||||
JavaDistribution["GraalVM"] = "graalvm";
|
||||
JavaDistribution["GraalVMCommunity"] = "graalvm-community";
|
||||
JavaDistribution["JetBrains"] = "jetbrains";
|
||||
})(JavaDistribution || (JavaDistribution = {}));
|
||||
function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
||||
@@ -78803,8 +78806,6 @@ function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
||||
return new installer_11.SapMachineDistribution(installerOptions);
|
||||
case JavaDistribution.GraalVM:
|
||||
return new installer_12.GraalVMDistribution(installerOptions);
|
||||
case JavaDistribution.GraalVMCommunity:
|
||||
return new installer_12.GraalVMCommunityDistribution(installerOptions);
|
||||
case JavaDistribution.JetBrains:
|
||||
return new installer_13.JetBrainsDistribution(installerOptions);
|
||||
default:
|
||||
@@ -79072,29 +79073,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.GraalVMCommunityDistribution = exports.GraalVMDistribution = void 0;
|
||||
exports.GraalVMDistribution = void 0;
|
||||
const core = __importStar(__nccwpck_require__(37484));
|
||||
const tc = __importStar(__nccwpck_require__(33472));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(79896));
|
||||
const path_1 = __importDefault(__nccwpck_require__(16928));
|
||||
const semver_1 = __importDefault(__nccwpck_require__(62088));
|
||||
const base_installer_1 = __nccwpck_require__(79935);
|
||||
const http_client_1 = __nccwpck_require__(54844);
|
||||
const util_1 = __nccwpck_require__(54527);
|
||||
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
|
||||
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 GRAALVM_COMMUNITY_ASSET_PREFIX = 'graalvm-community-jdk-';
|
||||
const GRAALVM_COMMUNITY_VERSION_PATTERN = /^\d+(?:\.\d+)*$/;
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
|
||||
const GRAALVM_MIN_VERSION = 17;
|
||||
const SUPPORTED_ARCHITECTURES = ['x64', 'aarch64'];
|
||||
class GraalVMDistribution extends base_installer_1.JavaBase {
|
||||
constructor(installerOptions, distributionName = 'GraalVM') {
|
||||
super(distributionName, installerOptions);
|
||||
constructor(installerOptions) {
|
||||
super('GraalVM', installerOptions);
|
||||
}
|
||||
downloadTool(javaRelease) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
@@ -79128,50 +79123,36 @@ class GraalVMDistribution extends base_installer_1.JavaBase {
|
||||
}
|
||||
findPackageForDownload(range) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
this.validateVersionRange(range);
|
||||
const arch = this.getSupportedArchitecture();
|
||||
// Add input validation
|
||||
if (!range || typeof range !== 'string') {
|
||||
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) {
|
||||
return this.findEABuildDownloadUrl(`${range}-ea`);
|
||||
}
|
||||
const { platform, extension, major } = this.validateStableBuildRequest(range);
|
||||
if (this.packageType !== 'jdk') {
|
||||
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 response = yield this.http.head(fileUrl);
|
||||
this.handleHttpResponse(response, 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) {
|
||||
return range.includes('.')
|
||||
? `${GRAALVM_DL_BASE}/${major}/archive/graalvm-jdk-${range}_${platform}-${arch}_bin.${extension}`
|
||||
@@ -79262,91 +79243,6 @@ class GraalVMDistribution extends base_installer_1.JavaBase {
|
||||
}
|
||||
}
|
||||
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);
|
||||
// GraalVM Community asset names embed the platform, architecture and
|
||||
// archive type, e.g. `graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz`.
|
||||
const assetSuffix = `_${platform}-${arch}_bin.${extension}`;
|
||||
const availableVersions = yield this.getAvailableVersions(assetSuffix);
|
||||
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;
|
||||
});
|
||||
}
|
||||
getAvailableVersions(assetSuffix) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const headers = (0, util_1.getGitHubHttpHeaders)();
|
||||
const versions = new Map();
|
||||
let releasesUrl = GRAALVM_COMMUNITY_RELEASES_URL;
|
||||
for (let pageIndex = 0; releasesUrl && pageIndex < util_1.MAX_PAGINATION_PAGES; pageIndex++) {
|
||||
const response = yield this.http.getJson(releasesUrl, headers);
|
||||
const releases = Array.isArray(response.result) ? response.result : [];
|
||||
if (releases.length === 0) {
|
||||
break;
|
||||
}
|
||||
for (const release of releases) {
|
||||
if (release.draft || release.prerelease) {
|
||||
continue;
|
||||
}
|
||||
for (const asset of (_a = release.assets) !== null && _a !== void 0 ? _a : []) {
|
||||
const version = this.extractAssetVersion(asset.name, assetSuffix);
|
||||
if (version) {
|
||||
versions.set(version, {
|
||||
version,
|
||||
url: asset.browser_download_url
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
releasesUrl = this.getNextReleasesUrl(response.headers);
|
||||
}
|
||||
return [...versions.values()];
|
||||
});
|
||||
}
|
||||
// Returns the GraalVM JDK version encoded in a release asset name when it
|
||||
// matches the requested platform/architecture/archive suffix, otherwise null.
|
||||
extractAssetVersion(assetName, assetSuffix) {
|
||||
if (!assetName.startsWith(GRAALVM_COMMUNITY_ASSET_PREFIX) ||
|
||||
!assetName.endsWith(assetSuffix)) {
|
||||
return null;
|
||||
}
|
||||
const rawVersion = assetName.slice(GRAALVM_COMMUNITY_ASSET_PREFIX.length, -assetSuffix.length);
|
||||
if (!GRAALVM_COMMUNITY_VERSION_PATTERN.test(rawVersion)) {
|
||||
return null;
|
||||
}
|
||||
return (0, util_1.convertVersionToSemver)(rawVersion);
|
||||
}
|
||||
getNextReleasesUrl(headers) {
|
||||
const nextUrl = (0, util_1.getNextPageUrlFromLinkHeader)(headers);
|
||||
if (nextUrl &&
|
||||
!(0, util_1.validatePaginationUrl)(nextUrl, GRAALVM_COMMUNITY_RELEASES_PAGE_ORIGIN)) {
|
||||
core.warning(`Ignoring pagination link with unexpected origin: ${nextUrl}`);
|
||||
return null;
|
||||
}
|
||||
return nextUrl;
|
||||
}
|
||||
}
|
||||
exports.GraalVMCommunityDistribution = GraalVMCommunityDistribution;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
+18
-59
@@ -10,10 +10,8 @@
|
||||
- [Alibaba Dragonwell](#Alibaba-Dragonwell)
|
||||
- [SapMachine](#SapMachine)
|
||||
- [GraalVM](#GraalVM)
|
||||
- [GraalVM Community](#GraalVM-Community)
|
||||
- [JetBrains](#JetBrains)
|
||||
- [Installing custom Java package type](#Installing-custom-Java-package-type)
|
||||
- [JavaFX Maven project](#JavaFX-Maven-project)
|
||||
- [Installing custom Java architecture](#Installing-custom-Java-architecture)
|
||||
- [Installing custom Java distribution from local file](#Installing-Java-from-local-file)
|
||||
- [Testing against different Java distributions](#Testing-against-different-Java-distributions)
|
||||
@@ -38,7 +36,7 @@ steps:
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '21'
|
||||
- run: java --version
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
### Adopt
|
||||
@@ -51,7 +49,7 @@ steps:
|
||||
with:
|
||||
distribution: 'adopt-hotspot'
|
||||
java-version: '11'
|
||||
- run: java --version
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
### Zulu
|
||||
@@ -64,7 +62,7 @@ steps:
|
||||
distribution: 'zulu'
|
||||
java-version: '21'
|
||||
java-package: jdk # optional (jdk, jre, jdk+fx or jre+fx) - defaults to jdk
|
||||
- run: java --version
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
### Liberica
|
||||
@@ -77,7 +75,7 @@ steps:
|
||||
distribution: 'liberica'
|
||||
java-version: '21'
|
||||
java-package: jdk # optional (jdk, jre, jdk+fx or jre+fx) - defaults to jdk
|
||||
- run: java --version
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
### Microsoft
|
||||
@@ -89,7 +87,7 @@ steps:
|
||||
with:
|
||||
distribution: 'microsoft'
|
||||
java-version: '21'
|
||||
- run: java --version
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
### Using Microsoft distribution on GHES
|
||||
@@ -118,7 +116,7 @@ steps:
|
||||
with:
|
||||
distribution: 'corretto'
|
||||
java-version: '21'
|
||||
- run: java --version
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
### Oracle
|
||||
@@ -131,7 +129,7 @@ steps:
|
||||
with:
|
||||
distribution: 'oracle'
|
||||
java-version: '21'
|
||||
- run: java --version
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
### Alibaba Dragonwell
|
||||
@@ -144,7 +142,7 @@ steps:
|
||||
with:
|
||||
distribution: 'dragonwell'
|
||||
java-version: '8'
|
||||
- run: java --version
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
### SapMachine
|
||||
@@ -156,7 +154,7 @@ steps:
|
||||
with:
|
||||
distribution: 'sapmachine'
|
||||
java-version: '21'
|
||||
- run: java --version
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
### GraalVM
|
||||
@@ -169,21 +167,6 @@ steps:
|
||||
with:
|
||||
distribution: 'graalvm'
|
||||
java-version: '21'
|
||||
- run: |
|
||||
java --version
|
||||
native-image --version
|
||||
```
|
||||
|
||||
### 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
|
||||
@@ -203,7 +186,7 @@ steps:
|
||||
with:
|
||||
distribution: 'jetbrains'
|
||||
java-version: '11'
|
||||
- run: java --version
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
The JetBrains installer uses the GitHub API to fetch the latest version. If you believe your project is going to be running into rate limits, you can provide a
|
||||
@@ -219,7 +202,7 @@ steps:
|
||||
java-package: 'jdk' # optional (jdk, jre, jdk+jcef, jre+jcef, jdk+ft, or jre+ft) - defaults to jdk
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: java --version
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
You can specify your package type (as shown in the [releases page](https://github.com/JetBrains/JetBrainsRuntime/releases/)) in the `java-package` parameter.
|
||||
@@ -242,31 +225,7 @@ steps:
|
||||
distribution: '<distribution>'
|
||||
java-version: '11'
|
||||
java-package: jdk # optional (jdk or jre) - defaults to jdk
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
### JavaFX Maven project
|
||||
|
||||
For JavaFX projects that use Maven, use `jdk+fx` (or `jre+fx`) as the `java-package` value together with a distribution that supports it (e.g. `zulu` or `liberica`). Then include the [`javafx-maven-plugin`](https://openjfx.io/openjfx-docs/#maven) in your `pom.xml` as described in the [Getting Started with JavaFX](https://openjfx.io/openjfx-docs/#maven) guide.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '21'
|
||||
java-package: jdk+fx
|
||||
cache: maven
|
||||
- name: Build with Maven
|
||||
run: mvn --no-transfer-progress compile
|
||||
```
|
||||
|
||||
To run the JavaFX application in CI:
|
||||
|
||||
```yaml
|
||||
- name: Run with Maven
|
||||
run: mvn --no-transfer-progress javafx:run
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
## Installing custom Java architecture
|
||||
@@ -279,7 +238,7 @@ steps:
|
||||
distribution: '<distribution>'
|
||||
java-version: '11'
|
||||
architecture: x86 # optional - default value derived from the runner machine
|
||||
- run: java --version
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
## Installing Java from local file
|
||||
@@ -297,7 +256,7 @@ steps:
|
||||
java-version: '11.0.0'
|
||||
architecture: x64
|
||||
|
||||
- run: java --version
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
If your use-case requires a custom distribution (in the example, alpine-linux is used) or a version that is not provided by setup-java and you want to always install the latest version during runtime, then you can use the following code to auto-download the latest JDK, determine the semver needed for setup-java, and setup-java will take care of the installation and caching on the VM:
|
||||
@@ -322,7 +281,7 @@ If your use-case requires a custom distribution (in the example, alpine-linux is
|
||||
jdkFile: ${{ runner.temp }}/java_package.tar.gz
|
||||
java-version: {{ steps.fetch_latest_jdk.outputs.java_version }}
|
||||
architecture: x64
|
||||
- run: java --version
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
## Testing against different Java distributions
|
||||
@@ -343,7 +302,7 @@ jobs:
|
||||
with:
|
||||
distribution: ${{ matrix.distribution }}
|
||||
java-version: ${{ matrix.java }}
|
||||
- run: java --version
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
#### Testing against different platforms
|
||||
@@ -363,7 +322,7 @@ jobs:
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: ${{ matrix.java }}
|
||||
- run: java --version
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
## Publishing using Apache Maven
|
||||
@@ -621,7 +580,7 @@ steps:
|
||||
distribution: 'temurin'
|
||||
java-version: '11'
|
||||
mvn-toolchain-id: 'some_other_id'
|
||||
- run: java --version
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
In case you install multiple versions of Java at once you can use the same syntax as used in `java-versions`. Please note that you have to declare an ID for all Java versions that will be installed or the `mvn-toolchain-id` instruction will be skipped wholesale due to mapping ambiguities.
|
||||
|
||||
Generated
+8
-8
@@ -21,7 +21,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/node": "^26.0.0",
|
||||
"@types/node": "^25.9.3",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@typescript-eslint/eslint-plugin": "^8.48.0",
|
||||
"@typescript-eslint/parser": "^8.61.1",
|
||||
@@ -1993,13 +1993,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "26.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.0.0.tgz",
|
||||
"integrity": "sha512-vf2YFi1iY9lHGwNJMs01biZFbKJkrZR1T6/MlzjhJLPdntOHLhTrDSnSVcdtvjihi4VQNlrFRIxLsDBlQpAipA==",
|
||||
"version": "25.9.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-25.9.3.tgz",
|
||||
"integrity": "sha512-603BddQMv3pUcr4U2dhujk83N2tTDVr/34wII2B6bJy6g+8WD6yUb11jszNs0gdi4PesVWl7ABt8nYMVpnLUcg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~8.3.0"
|
||||
"undici-types": ">=7.24.0 <7.24.7"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/semver": {
|
||||
@@ -6428,9 +6428,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "8.3.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.3.0.tgz",
|
||||
"integrity": "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ==",
|
||||
"version": "7.24.6",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz",
|
||||
"integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/node": "^26.0.0",
|
||||
"@types/node": "^25.9.3",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@typescript-eslint/eslint-plugin": "^8.48.0",
|
||||
"@typescript-eslint/parser": "^8.61.1",
|
||||
|
||||
+5
-1
@@ -28,7 +28,11 @@ const supportedPackageManager: PackageManager[] = [
|
||||
join(os.homedir(), '.m2', 'wrapper', 'dists')
|
||||
],
|
||||
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven
|
||||
pattern: ['**/pom.xml', '**/.mvn/wrapper/maven-wrapper.properties']
|
||||
pattern: [
|
||||
'**/pom.xml',
|
||||
'**/.mvn/wrapper/maven-wrapper.properties',
|
||||
'**/.mvn/extensions.xml'
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'gradle',
|
||||
|
||||
@@ -11,10 +11,7 @@ import {CorrettoDistribution} from './corretto/installer';
|
||||
import {OracleDistribution} from './oracle/installer';
|
||||
import {DragonwellDistribution} from './dragonwell/installer';
|
||||
import {SapMachineDistribution} from './sapmachine/installer';
|
||||
import {
|
||||
GraalVMCommunityDistribution,
|
||||
GraalVMDistribution
|
||||
} from './graalvm/installer';
|
||||
import {GraalVMDistribution} from './graalvm/installer';
|
||||
import {JetBrainsDistribution} from './jetbrains/installer';
|
||||
|
||||
enum JavaDistribution {
|
||||
@@ -32,7 +29,6 @@ enum JavaDistribution {
|
||||
Dragonwell = 'dragonwell',
|
||||
SapMachine = 'sapmachine',
|
||||
GraalVM = 'graalvm',
|
||||
GraalVMCommunity = 'graalvm-community',
|
||||
JetBrains = 'jetbrains'
|
||||
}
|
||||
|
||||
@@ -78,8 +74,6 @@ export function getJavaDistribution(
|
||||
return new SapMachineDistribution(installerOptions);
|
||||
case JavaDistribution.GraalVM:
|
||||
return new GraalVMDistribution(installerOptions);
|
||||
case JavaDistribution.GraalVMCommunity:
|
||||
return new GraalVMCommunityDistribution(installerOptions);
|
||||
case JavaDistribution.JetBrains:
|
||||
return new JetBrainsDistribution(installerOptions);
|
||||
default:
|
||||
|
||||
@@ -2,7 +2,6 @@ import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import semver from 'semver';
|
||||
import {JavaBase} from '../base-installer';
|
||||
import {HttpCodes} from '@actions/http-client';
|
||||
import {GraalVMEAVersion} from './models';
|
||||
@@ -12,26 +11,14 @@ import {
|
||||
JavaInstallerResults
|
||||
} from '../base-models';
|
||||
import {
|
||||
convertVersionToSemver,
|
||||
extractJdkFile,
|
||||
getDownloadArchiveExtension,
|
||||
getGitHubHttpHeaders,
|
||||
getNextPageUrlFromLinkHeader,
|
||||
isVersionSatisfies,
|
||||
MAX_PAGINATION_PAGES,
|
||||
renameWinArchive,
|
||||
validatePaginationUrl
|
||||
renameWinArchive
|
||||
} from '../../util';
|
||||
|
||||
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
|
||||
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 GRAALVM_COMMUNITY_ASSET_PREFIX = 'graalvm-community-jdk-';
|
||||
const GRAALVM_COMMUNITY_VERSION_PATTERN = /^\d+(?:\.\d+)*$/;
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
|
||||
const GRAALVM_MIN_VERSION = 17;
|
||||
@@ -39,23 +26,9 @@ const SUPPORTED_ARCHITECTURES = ['x64', 'aarch64'] as const;
|
||||
type SupportedArchitecture = (typeof SUPPORTED_ARCHITECTURES)[number];
|
||||
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 {
|
||||
constructor(
|
||||
installerOptions: JavaInstallerOptions,
|
||||
distributionName = 'GraalVM'
|
||||
) {
|
||||
super(distributionName, installerOptions);
|
||||
constructor(installerOptions: JavaInstallerOptions) {
|
||||
super('GraalVM', installerOptions);
|
||||
}
|
||||
|
||||
protected async downloadTool(
|
||||
@@ -112,36 +85,11 @@ export class GraalVMDistribution extends JavaBase {
|
||||
protected async findPackageForDownload(
|
||||
range: string
|
||||
): Promise<JavaDownloadRelease> {
|
||||
this.validateVersionRange(range);
|
||||
const arch = this.getSupportedArchitecture();
|
||||
|
||||
if (!this.stable) {
|
||||
return this.findEABuildDownloadUrl(`${range}-ea`);
|
||||
}
|
||||
|
||||
const {platform, extension, major} = this.validateStableBuildRequest(range);
|
||||
|
||||
const fileUrl = this.constructFileUrl(
|
||||
range,
|
||||
major,
|
||||
platform,
|
||||
arch,
|
||||
extension
|
||||
);
|
||||
|
||||
const response = await this.http.head(fileUrl);
|
||||
this.handleHttpResponse(response, range);
|
||||
|
||||
return {url: fileUrl, version: range};
|
||||
}
|
||||
|
||||
protected validateVersionRange(range: string): void {
|
||||
// Add input validation
|
||||
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(
|
||||
@@ -149,18 +97,12 @@ export class GraalVMDistribution extends JavaBase {
|
||||
);
|
||||
}
|
||||
|
||||
return arch as SupportedArchitecture;
|
||||
}
|
||||
if (!this.stable) {
|
||||
return this.findEABuildDownloadUrl(`${range}-ea`);
|
||||
}
|
||||
|
||||
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`
|
||||
);
|
||||
throw new Error('GraalVM provides only the `jdk` package type');
|
||||
}
|
||||
|
||||
const platform = this.getPlatform();
|
||||
@@ -174,15 +116,22 @@ export class GraalVMDistribution extends JavaBase {
|
||||
|
||||
if (majorVersion < GRAALVM_MIN_VERSION) {
|
||||
throw new Error(
|
||||
`${this.distribution} is only supported for JDK ${GRAALVM_MIN_VERSION} and later. Requested version: ${major}`
|
||||
`GraalVM is only supported for JDK ${GRAALVM_MIN_VERSION} and later. Requested version: ${major}`
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
platform,
|
||||
const fileUrl = this.constructFileUrl(
|
||||
range,
|
||||
major,
|
||||
platform,
|
||||
arch,
|
||||
extension
|
||||
};
|
||||
);
|
||||
|
||||
const response = await this.http.head(fileUrl);
|
||||
this.handleHttpResponse(response, range);
|
||||
|
||||
return {url: fileUrl, version: range};
|
||||
}
|
||||
|
||||
private constructFileUrl(
|
||||
@@ -331,131 +280,3 @@ export class GraalVMDistribution extends JavaBase {
|
||||
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);
|
||||
// GraalVM Community asset names embed the platform, architecture and
|
||||
// archive type, e.g. `graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz`.
|
||||
const assetSuffix = `_${platform}-${arch}_bin.${extension}`;
|
||||
const availableVersions = await this.getAvailableVersions(assetSuffix);
|
||||
|
||||
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 getAvailableVersions(
|
||||
assetSuffix: string
|
||||
): Promise<JavaDownloadRelease[]> {
|
||||
const headers = getGitHubHttpHeaders();
|
||||
const versions = new Map<string, JavaDownloadRelease>();
|
||||
let releasesUrl: string | null = GRAALVM_COMMUNITY_RELEASES_URL;
|
||||
|
||||
for (
|
||||
let pageIndex = 0;
|
||||
releasesUrl && pageIndex < MAX_PAGINATION_PAGES;
|
||||
pageIndex++
|
||||
) {
|
||||
const response = await this.http.getJson<GraalVMCommunityRelease[]>(
|
||||
releasesUrl,
|
||||
headers
|
||||
);
|
||||
|
||||
const releases = Array.isArray(response.result) ? response.result : [];
|
||||
if (releases.length === 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
for (const release of releases) {
|
||||
if (release.draft || release.prerelease) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const asset of release.assets ?? []) {
|
||||
const version = this.extractAssetVersion(asset.name, assetSuffix);
|
||||
if (version) {
|
||||
versions.set(version, {
|
||||
version,
|
||||
url: asset.browser_download_url
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
releasesUrl = this.getNextReleasesUrl(response.headers);
|
||||
}
|
||||
|
||||
return [...versions.values()];
|
||||
}
|
||||
|
||||
// Returns the GraalVM JDK version encoded in a release asset name when it
|
||||
// matches the requested platform/architecture/archive suffix, otherwise null.
|
||||
private extractAssetVersion(
|
||||
assetName: string,
|
||||
assetSuffix: string
|
||||
): string | null {
|
||||
if (
|
||||
!assetName.startsWith(GRAALVM_COMMUNITY_ASSET_PREFIX) ||
|
||||
!assetName.endsWith(assetSuffix)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const rawVersion = assetName.slice(
|
||||
GRAALVM_COMMUNITY_ASSET_PREFIX.length,
|
||||
-assetSuffix.length
|
||||
);
|
||||
|
||||
if (!GRAALVM_COMMUNITY_VERSION_PATTERN.test(rawVersion)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return convertVersionToSemver(rawVersion);
|
||||
}
|
||||
|
||||
private getNextReleasesUrl(
|
||||
headers: Record<string, string | string[] | undefined>
|
||||
): string | null {
|
||||
const nextUrl = getNextPageUrlFromLinkHeader(headers);
|
||||
if (
|
||||
nextUrl &&
|
||||
!validatePaginationUrl(nextUrl, GRAALVM_COMMUNITY_RELEASES_PAGE_ORIGIN)
|
||||
) {
|
||||
core.warning(
|
||||
`Ignoring pagination link with unexpected origin: ${nextUrl}`
|
||||
);
|
||||
return null;
|
||||
}
|
||||
return nextUrl;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user