Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
78078da0cd | ||
![]() |
5caaba646e | ||
![]() |
0ab4596768 | ||
![]() |
4075bfc1b5 | ||
![]() |
5b86b67f5b | ||
![]() |
b943a4ed87 | ||
![]() |
c16064d22c | ||
![]() |
91f49aa1b0 |
22
.github/workflows/e2e-versions.yml
vendored
22
.github/workflows/e2e-versions.yml
vendored
@ -29,12 +29,15 @@ jobs:
|
||||
'liberica',
|
||||
'microsoft',
|
||||
'semeru',
|
||||
'corretto'
|
||||
'corretto',
|
||||
'dragonwell'
|
||||
] # internally 'adopt-hotspot' is the same as 'adopt'
|
||||
version: ['8', '11', '17']
|
||||
exclude:
|
||||
- distribution: microsoft
|
||||
version: 8
|
||||
- distribution: dragonwell
|
||||
os: macos-latest
|
||||
include:
|
||||
- distribution: oracle
|
||||
os: macos-latest
|
||||
@ -45,6 +48,7 @@ jobs:
|
||||
- distribution: oracle
|
||||
os: ubuntu-latest
|
||||
version: 20
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@ -75,6 +79,12 @@ jobs:
|
||||
- distribution: oracle
|
||||
os: ubuntu-latest
|
||||
version: '20.0.1'
|
||||
- distribution: dragonwell
|
||||
os: ubuntu-latest
|
||||
version: '11.0'
|
||||
- distribution: dragonwell
|
||||
os: ubuntu-latest
|
||||
version: '11.0.13+9'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@ -96,7 +106,10 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
distribution: ['temurin', 'zulu', 'liberica']
|
||||
distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
|
||||
exclude:
|
||||
- distribution: dragonwell
|
||||
os: macos-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@ -119,7 +132,10 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
distribution: ['temurin', 'zulu', 'liberica']
|
||||
distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
|
||||
exclude:
|
||||
- distribution: dragonwell
|
||||
os: macos-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
BIN
.licenses/npm/@actions/cache.dep.yml
generated
BIN
.licenses/npm/@actions/cache.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/http-client-2.2.0.dep.yml
generated
Normal file
BIN
.licenses/npm/@actions/http-client-2.2.0.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@azure/abort-controller.dep.yml
generated
BIN
.licenses/npm/@azure/abort-controller.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@fastify/busboy.dep.yml
generated
Normal file
BIN
.licenses/npm/@fastify/busboy.dep.yml
generated
Normal file
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/psl.dep.yml
generated
BIN
.licenses/npm/psl.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/punycode.dep.yml
generated
BIN
.licenses/npm/punycode.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/semver-6.3.0.dep.yml
generated
BIN
.licenses/npm/semver-6.3.0.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/tough-cookie.dep.yml
generated
BIN
.licenses/npm/tough-cookie.dep.yml
generated
Binary file not shown.
Binary file not shown.
28
README.md
28
README.md
@ -5,7 +5,7 @@
|
||||
[](https://github.com/actions/setup-java/actions/workflows/e2e-cache.yml)
|
||||
|
||||
The `setup-java` action provides the following functionality for GitHub Actions runners:
|
||||
- Downloading and setting up a requested version of Java. See [Usage](#Usage) for a list of supported distributions.
|
||||
- Downloading and setting up a requested version of Java. See [Usage](#usage) for a list of supported distributions.
|
||||
- Extracting and caching custom version of Java from a local file.
|
||||
- Configuring runner for publishing using Apache Maven.
|
||||
- Configuring runner for publishing using Gradle.
|
||||
@ -31,7 +31,7 @@ This action allows you to work with Java and Scala projects.
|
||||
|
||||
- `distribution`: _(required)_ Java [distribution](#supported-distributions).
|
||||
|
||||
- `java-package`: The packaging variant of the choosen distribution. Possible values: `jdk`, `jre`, `jdk+fx`, `jre+fx`. Default value: `jdk`.
|
||||
- `java-package`: The packaging variant of the chosen distribution. Possible values: `jdk`, `jre`, `jdk+fx`, `jre+fx`. Default value: `jdk`.
|
||||
|
||||
- `architecture`: The target architecture of the package. Possible values: `x86`, `x64`, `armv7`, `aarch64`, `ppc64le`. Default value: Derived from the runner machine.
|
||||
|
||||
@ -39,12 +39,12 @@ This action allows you to work with Java and Scala projects.
|
||||
|
||||
- `check-latest`: Setting this option makes the action to check for the latest available version for the version spec.
|
||||
|
||||
- `cache`: Quick [setup caching](#caching-packages-dependencies) for the dependencies managed through one of the predifined package managers. It can be one of "maven", "gradle" or "sbt".
|
||||
- `cache`: Quick [setup caching](#caching-packages-dependencies) for the dependencies managed through one of the predefined package managers. It can be one of "maven", "gradle" or "sbt".
|
||||
|
||||
#### Maven options
|
||||
The action has a bunch of inputs to generate maven's [settings.xml](https://maven.apache.org/settings.html) on the fly and pass the values to Apache Maven GPG Plugin as well as Apache Maven Toolchains. See [advanced usage](docs/advanced-usage.md) for more.
|
||||
|
||||
- `overwrite-settings`: By default action overwrites the settings.xml. In order to skip generation of file if it exists set this to `false`.
|
||||
- `overwrite-settings`: By default action overwrites the settings.xml. In order to skip generation of file if it exists, set this to `false`.
|
||||
|
||||
- `server-id`: ID of the distributionManagement repository in the pom.xml file. Default is `github`.
|
||||
|
||||
@ -56,7 +56,7 @@ This action allows you to work with Java and Scala projects.
|
||||
|
||||
- `gpg-private-key`: GPG private key to import. Default is empty string.
|
||||
|
||||
- `gpg-passphrase`: description: Environment variable name for the GPG private key passphrase. Default is GPG_PASSPHRASE.
|
||||
- `gpg-passphrase`: Environment variable name for the GPG private key passphrase. Default is GPG_PASSPHRASE.
|
||||
|
||||
- `mvn-toolchain-id`: Name of Maven Toolchain ID if the default name of `${distribution}_${java-version}` is not wanted.
|
||||
|
||||
@ -105,6 +105,7 @@ Currently, the following distributions are supported:
|
||||
| `corretto` | Amazon Corretto Build of OpenJDK | [Link](https://aws.amazon.com/corretto/) | [Link](https://aws.amazon.com/corretto/faqs/)
|
||||
| `semeru` | IBM Semeru Runtime Open Edition | [Link](https://developer.ibm.com/languages/java/semeru-runtimes/downloads/) | [Link](https://openjdk.java.net/legal/gplv2+ce.html) |
|
||||
| `oracle` | Oracle JDK | [Link](https://www.oracle.com/java/technologies/downloads/) | [Link](https://java.com/freeuselicense)
|
||||
| `dragonwell` | Alibaba Dragonwell JDK | [Link](https://dragonwell-jdk.io/) | [Link](https://www.aliyun.com/product/dragonwell/)
|
||||
|
||||
**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.
|
||||
|
||||
@ -160,6 +161,22 @@ steps:
|
||||
run: sbt package
|
||||
```
|
||||
|
||||
#### Cache segment restore timeout
|
||||
Usually, cache gets downloaded in multiple segments of fixed sizes. Sometimes, a segment download gets stuck, which causes the workflow job to be stuck. The cache segment download timeout [was introduced](https://github.com/actions/toolkit/tree/main/packages/cache#cache-segment-restore-timeout) to solve this issue as it allows the segment download to get aborted and hence allows the job to proceed with a cache miss. The default value of the cache segment download timeout is set to 10 minutes and can be customized by specifying an environment variable named `SEGMENT_DOWNLOAD_TIMEOUT_MINS` with a timeout value in minutes.
|
||||
|
||||
```yaml
|
||||
env:
|
||||
SEGMENT_DOWNLOAD_TIMEOUT_MINS: '5'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
cache: 'gradle'
|
||||
- run: ./gradlew build --no-daemon
|
||||
```
|
||||
|
||||
### Check latest
|
||||
|
||||
In the basic examples above, the `check-latest` flag defaults to `false`. When set to `false`, the action tries to first resolve a version of Java from the local tool cache on the runner. If unable to find a specific version in the cache, the action will download a version of Java. Use the default or set `check-latest` to `false` if you prefer a faster more consistent setup experience that prioritizes trying to use the cached versions at the expense of newer versions sometimes being available for download.
|
||||
@ -227,6 +244,7 @@ In the example above multiple JDKs are installed for the same job. The result af
|
||||
- [Microsoft](docs/advanced-usage.md#Microsoft)
|
||||
- [Amazon Corretto](docs/advanced-usage.md#Amazon-Corretto)
|
||||
- [Oracle](docs/advanced-usage.md#Oracle)
|
||||
- [Alibaba Dragonwell](docs/advanced-usage.md#Alibaba-Dragonwell)
|
||||
- [Installing custom Java package type](docs/advanced-usage.md#Installing-custom-Java-package-type)
|
||||
- [Installing custom Java architecture](docs/advanced-usage.md#Installing-custom-Java-architecture)
|
||||
- [Installing custom Java distribution from local file](docs/advanced-usage.md#Installing-Java-from-local-file)
|
||||
|
1138
__tests__/data/dragonwell.json
Normal file
1138
__tests__/data/dragonwell.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,41 @@
|
||||
[
|
||||
{
|
||||
"version": "21.0.0",
|
||||
"stable": true,
|
||||
"release_url": "https://aka.ms/download-jdk",
|
||||
"files": [
|
||||
{
|
||||
"filename": "microsoft-jdk-21.0.0-macos-x64.tar.gz",
|
||||
"arch": "x64",
|
||||
"platform": "darwin",
|
||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-macos-x64.tar.gz"
|
||||
},
|
||||
{
|
||||
"filename": "microsoft-jdk-21.0.0-linux-x64.tar.gz",
|
||||
"arch": "x64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-linux-x64.tar.gz"
|
||||
},
|
||||
{
|
||||
"filename": "microsoft-jdk-21.0.0-windows-x64.zip",
|
||||
"arch": "x64",
|
||||
"platform": "win32",
|
||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-windows-x64.zip"
|
||||
},
|
||||
{
|
||||
"filename": "microsoft-jdk-21.0.0-macos-aarch64.tar.gz",
|
||||
"arch": "aarch64",
|
||||
"platform": "darwin",
|
||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-macos-aarch64.tar.gz"
|
||||
},
|
||||
{
|
||||
"filename": "microsoft-jdk-21.0.0-linux-aarch64.tar.gz",
|
||||
"arch": "aarch64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-linux-aarch64.tar.gz"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "17.0.7",
|
||||
"stable": true,
|
||||
|
226
__tests__/distributors/dragonwell-installer.test.ts
Normal file
226
__tests__/distributors/dragonwell-installer.test.ts
Normal file
@ -0,0 +1,226 @@
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
import {DragonwellDistribution} from '../../src/distributions/dragonwell/installer';
|
||||
import * as utils from '../../src/util';
|
||||
|
||||
import manifestData from '../data/dragonwell.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
spyHttpClient.mockReturnValue({
|
||||
statusCode: 200,
|
||||
headers: {},
|
||||
result: manifestData
|
||||
});
|
||||
|
||||
spyUtilGetDownloadArchiveExtension = jest.spyOn(
|
||||
utils,
|
||||
'getDownloadArchiveExtension'
|
||||
);
|
||||
spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
jest.clearAllMocks();
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
const mockPlatform = (
|
||||
distribution: DragonwellDistribution,
|
||||
platform: string
|
||||
) => {
|
||||
distribution['getPlatformOption'] = () => platform;
|
||||
const mockedExtension = platform == 'windows' ? 'zip' : 'tar.gz';
|
||||
spyUtilGetDownloadArchiveExtension.mockReturnValue(mockedExtension);
|
||||
};
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
it.each([
|
||||
['8', 'x86', 'linux', 0],
|
||||
['8', 'aarch64', 'linux', 24],
|
||||
['8.6.6', 'x64', 'linux', 27],
|
||||
['8', 'x86', 'anolis', 0],
|
||||
['8', 'x86', 'windows', 0],
|
||||
['8', 'x86', 'mac', 0],
|
||||
['11', 'x64', 'linux', 27],
|
||||
['11', 'aarch64', 'linux', 24],
|
||||
['17', 'riscv', 'linux', 0],
|
||||
['16.0.1', 'x64', 'linux', 27]
|
||||
])(
|
||||
'should get right number of available versions from JSON',
|
||||
async (
|
||||
jdkVersion: string,
|
||||
arch: string,
|
||||
platform: string,
|
||||
len: number
|
||||
) => {
|
||||
const distribution = new DragonwellDistribution({
|
||||
version: jdkVersion,
|
||||
architecture: arch,
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
mockPlatform(distribution, platform);
|
||||
|
||||
const availableVersions = await distribution['getAvailableVersions']();
|
||||
expect(availableVersions).not.toBeNull();
|
||||
expect(availableVersions.length).toBe(len);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe('findPackageForDownload', () => {
|
||||
it.each([
|
||||
[
|
||||
'8',
|
||||
'linux',
|
||||
'x64',
|
||||
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_linux.tar.gz'
|
||||
],
|
||||
[
|
||||
'8',
|
||||
'linux',
|
||||
'aarch64',
|
||||
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_aarch64_linux.tar.gz'
|
||||
],
|
||||
[
|
||||
'8',
|
||||
'windows',
|
||||
'x64',
|
||||
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_windows.zip'
|
||||
],
|
||||
[
|
||||
'8.13.14',
|
||||
'linux',
|
||||
'x64',
|
||||
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_linux.tar.gz'
|
||||
],
|
||||
[
|
||||
'11',
|
||||
'linux',
|
||||
'x64',
|
||||
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_linux.tar.gz'
|
||||
],
|
||||
[
|
||||
'11',
|
||||
'linux',
|
||||
'aarch64',
|
||||
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_aarch64_linux.tar.gz'
|
||||
],
|
||||
[
|
||||
'11',
|
||||
'windows',
|
||||
'x64',
|
||||
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_windows.zip'
|
||||
],
|
||||
[
|
||||
'11',
|
||||
'alpine-linux',
|
||||
'x64',
|
||||
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_alpine-linux.tar.gz'
|
||||
],
|
||||
[
|
||||
'11.0.17',
|
||||
'linux',
|
||||
'x64',
|
||||
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_linux.tar.gz'
|
||||
],
|
||||
[
|
||||
'17',
|
||||
'linux',
|
||||
'x64',
|
||||
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_x64_linux.tar.gz'
|
||||
],
|
||||
[
|
||||
'17',
|
||||
'linux',
|
||||
'aarch64',
|
||||
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_aarch64_linux.tar.gz'
|
||||
],
|
||||
[
|
||||
'17',
|
||||
'windows',
|
||||
'x64',
|
||||
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_x64_windows.zip'
|
||||
],
|
||||
[
|
||||
'17',
|
||||
'alpine-linux',
|
||||
'x64',
|
||||
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_x64_alpine-linux.tar.gz'
|
||||
],
|
||||
[
|
||||
'17.0.4',
|
||||
'linux',
|
||||
'x64',
|
||||
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.4.0.4%2B8_jdk-17.0.4-ga/Alibaba_Dragonwell_Standard_17.0.4.0.4%2B8_x64_linux.tar.gz'
|
||||
]
|
||||
])(
|
||||
'should return proper link according to the specified java-version, platform and arch',
|
||||
async (
|
||||
jdkVersion: string,
|
||||
platform: string,
|
||||
arch: string,
|
||||
expectedLink: string
|
||||
) => {
|
||||
const distribution = new DragonwellDistribution({
|
||||
version: jdkVersion,
|
||||
architecture: arch,
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
mockPlatform(distribution, platform);
|
||||
|
||||
const availableVersion = await distribution['findPackageForDownload'](
|
||||
jdkVersion
|
||||
);
|
||||
expect(availableVersion).not.toBeNull();
|
||||
expect(availableVersion.url).toBe(expectedLink);
|
||||
}
|
||||
);
|
||||
|
||||
it.each([
|
||||
['8', 'alpine-linux', 'x64'],
|
||||
['8', 'macos', 'aarch64'],
|
||||
['11', 'macos', 'aarch64'],
|
||||
['17', 'linux', 'riscv']
|
||||
])(
|
||||
'should throw when required version of JDK can not be found in the JSON',
|
||||
async (jdkVersion: string, platform: string, arch: string) => {
|
||||
const distribution = new DragonwellDistribution({
|
||||
version: jdkVersion,
|
||||
architecture: arch,
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
mockPlatform(distribution, platform);
|
||||
|
||||
await expect(
|
||||
distribution['findPackageForDownload'](jdkVersion)
|
||||
).rejects.toThrow(
|
||||
`Couldn't find any satisfied version for the specified java-version: "${jdkVersion}" and architecture: "${arch}".`
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
it('should throw when required package type is not jdk', async () => {
|
||||
const jdkVersion = '17';
|
||||
const arch = 'x64';
|
||||
const platform = 'linux';
|
||||
const distribution = new DragonwellDistribution({
|
||||
version: jdkVersion,
|
||||
architecture: arch,
|
||||
packageType: 'jre',
|
||||
checkLatest: false
|
||||
});
|
||||
mockPlatform(distribution, platform);
|
||||
await expect(
|
||||
distribution['findPackageForDownload'](jdkVersion)
|
||||
).rejects.toThrow('Dragonwell provides only the `jdk` package type');
|
||||
});
|
||||
});
|
||||
});
|
@ -29,6 +29,11 @@ describe('findPackageForDownload', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[
|
||||
'21.x',
|
||||
'21.0.0',
|
||||
'https://aka.ms/download-jdk/microsoft-jdk-21.0.0-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
|
||||
],
|
||||
[
|
||||
'17.0.1',
|
||||
'17.0.1+12.1',
|
||||
|
@ -77,9 +77,9 @@ describe('toolchains tests', () => {
|
||||
};
|
||||
|
||||
const result = `<?xml version="1.0"?>
|
||||
<toolchains xmlns="https://maven.apache.org/TOOLCHAINS/1.1.0"
|
||||
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="https://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd">
|
||||
<toolchains xmlns="http://maven.apache.org/TOOLCHAINS/1.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd">
|
||||
<toolchain>
|
||||
<type>jdk</type>
|
||||
<provides>
|
||||
@ -248,9 +248,9 @@ describe('toolchains tests', () => {
|
||||
};
|
||||
|
||||
const expectedToolchains = `<?xml version="1.0"?>
|
||||
<toolchains xmlns="https://maven.apache.org/TOOLCHAINS/1.1.0"
|
||||
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="https://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd">
|
||||
<toolchains xmlns="http://maven.apache.org/TOOLCHAINS/1.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd">
|
||||
<toolchain>
|
||||
<type>jdk</type>
|
||||
<provides>
|
||||
|
24392
dist/cleanup/index.js
vendored
24392
dist/cleanup/index.js
vendored
File diff suppressed because one or more lines are too long
27816
dist/setup/index.js
vendored
27816
dist/setup/index.js
vendored
File diff suppressed because one or more lines are too long
@ -7,6 +7,7 @@
|
||||
- [Microsoft](#Microsoft)
|
||||
- [Amazon Corretto](#Amazon-Corretto)
|
||||
- [Oracle](#Oracle)
|
||||
- [Alibaba Dragonwell](#Alibaba-Dragonwell)
|
||||
- [Installing custom Java package type](#Installing-custom-Java-package-type)
|
||||
- [Installing custom Java architecture](#Installing-custom-Java-architecture)
|
||||
- [Installing custom Java distribution from local file](#Installing-Java-from-local-file)
|
||||
@ -124,6 +125,18 @@ steps:
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
### Alibaba Dragonwell
|
||||
**NOTE:** Alibaba Dragonwell only provides jdk.
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'dragonwell'
|
||||
java-version: '8'
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
|
||||
## Installing custom Java package type
|
||||
```yaml
|
||||
steps:
|
||||
|
2924
package-lock.json
generated
2924
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -47,8 +47,8 @@
|
||||
"eslint-config-prettier": "^8.6.0",
|
||||
"eslint-plugin-jest": "^27.2.1",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"jest": "^27.2.5",
|
||||
"jest-circus": "^27.2.5",
|
||||
"jest": "^27.5.1",
|
||||
"jest-circus": "^27.5.1",
|
||||
"prettier": "^2.8.4",
|
||||
"ts-jest": "^27.0.5",
|
||||
"typescript": "^4.2.3"
|
||||
|
@ -9,6 +9,7 @@ import {MicrosoftDistributions} from './microsoft/installer';
|
||||
import {SemeruDistribution} from './semeru/installer';
|
||||
import {CorrettoDistribution} from './corretto/installer';
|
||||
import {OracleDistribution} from './oracle/installer';
|
||||
import {DragonwellDistribution} from './dragonwell/installer';
|
||||
|
||||
enum JavaDistribution {
|
||||
Adopt = 'adopt',
|
||||
@ -21,7 +22,8 @@ enum JavaDistribution {
|
||||
Microsoft = 'microsoft',
|
||||
Semeru = 'semeru',
|
||||
Corretto = 'corretto',
|
||||
Oracle = 'oracle'
|
||||
Oracle = 'oracle',
|
||||
Dragonwell = 'dragonwell'
|
||||
}
|
||||
|
||||
export function getJavaDistribution(
|
||||
@ -60,6 +62,8 @@ export function getJavaDistribution(
|
||||
return new CorrettoDistribution(installerOptions);
|
||||
case JavaDistribution.Oracle:
|
||||
return new OracleDistribution(installerOptions);
|
||||
case JavaDistribution.Dragonwell:
|
||||
return new DragonwellDistribution(installerOptions);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
240
src/distributions/dragonwell/installer.ts
Normal file
240
src/distributions/dragonwell/installer.ts
Normal file
@ -0,0 +1,240 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import semver from 'semver';
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import {JavaBase} from '../base-installer';
|
||||
import {
|
||||
convertVersionToSemver,
|
||||
extractJdkFile,
|
||||
getDownloadArchiveExtension,
|
||||
getGitHubHttpHeaders,
|
||||
isVersionSatisfies
|
||||
} from '../../util';
|
||||
import {IDragonwellVersions, IDragonwellAllVersions} from './models';
|
||||
import {
|
||||
JavaDownloadRelease,
|
||||
JavaInstallerOptions,
|
||||
JavaInstallerResults
|
||||
} from '../base-models';
|
||||
|
||||
export class DragonwellDistribution extends JavaBase {
|
||||
constructor(installerOptions: JavaInstallerOptions) {
|
||||
super('Dragonwell', installerOptions);
|
||||
}
|
||||
|
||||
protected async findPackageForDownload(
|
||||
version: string
|
||||
): Promise<JavaDownloadRelease> {
|
||||
if (!this.stable) {
|
||||
throw new Error('Early access versions are not supported by Dragonwell');
|
||||
}
|
||||
|
||||
if (this.packageType !== 'jdk') {
|
||||
throw new Error('Dragonwell provides only the `jdk` package type');
|
||||
}
|
||||
|
||||
const availableVersions = await this.getAvailableVersions();
|
||||
|
||||
const matchedVersions = availableVersions
|
||||
.filter(item => {
|
||||
return isVersionSatisfies(version, item.jdk_version);
|
||||
})
|
||||
.map(item => {
|
||||
return {
|
||||
version: item.jdk_version,
|
||||
url: item.download_link
|
||||
} as JavaDownloadRelease;
|
||||
});
|
||||
|
||||
if (!matchedVersions.length) {
|
||||
throw new Error(
|
||||
`Couldn't find any satisfied version for the specified java-version: "${version}" and architecture: "${this.architecture}".`
|
||||
);
|
||||
}
|
||||
|
||||
const resolvedVersion = matchedVersions[0];
|
||||
return resolvedVersion;
|
||||
}
|
||||
|
||||
private async getAvailableVersions(): Promise<IDragonwellVersions[]> {
|
||||
const platform = this.getPlatformOption();
|
||||
const arch = this.distributionArchitecture();
|
||||
|
||||
let fetchedDragonwellJson = await this.fetchJsonFromPrimaryUrl();
|
||||
|
||||
if (!fetchedDragonwellJson) {
|
||||
fetchedDragonwellJson = await this.fetchJsonFromBackupUrl();
|
||||
}
|
||||
|
||||
if (!fetchedDragonwellJson) {
|
||||
throw new Error(
|
||||
`Couldn't fetch Dragonwell versions information from both primary and backup urls`
|
||||
);
|
||||
}
|
||||
|
||||
core.debug(
|
||||
'Successfully fetched information about available Dragonwell versions'
|
||||
);
|
||||
|
||||
const availableVersions = this.parseVersions(
|
||||
platform,
|
||||
arch,
|
||||
fetchedDragonwellJson
|
||||
);
|
||||
|
||||
if (core.isDebug()) {
|
||||
core.startGroup('Print information about available versions');
|
||||
core.debug(availableVersions.map(item => item.jdk_version).join(', '));
|
||||
core.endGroup();
|
||||
}
|
||||
|
||||
return availableVersions;
|
||||
}
|
||||
|
||||
protected async downloadTool(
|
||||
javaRelease: JavaDownloadRelease
|
||||
): Promise<JavaInstallerResults> {
|
||||
core.info(
|
||||
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
||||
);
|
||||
const javaArchivePath = await tc.downloadTool(javaRelease.url);
|
||||
|
||||
core.info(`Extracting Java archive...`);
|
||||
|
||||
const extractedJavaPath = await extractJdkFile(
|
||||
javaArchivePath,
|
||||
getDownloadArchiveExtension()
|
||||
);
|
||||
|
||||
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
||||
const archivePath = path.join(extractedJavaPath, archiveName);
|
||||
const version = this.getToolcacheVersionName(javaRelease.version);
|
||||
|
||||
const javaPath = await tc.cacheDir(
|
||||
archivePath,
|
||||
this.toolcacheFolderName,
|
||||
version,
|
||||
this.architecture
|
||||
);
|
||||
|
||||
return {version: javaRelease.version, path: javaPath};
|
||||
}
|
||||
|
||||
private parseVersions(
|
||||
platform: string,
|
||||
arch: string,
|
||||
dragonwellVersions: IDragonwellAllVersions
|
||||
): IDragonwellVersions[] {
|
||||
const eligibleVersions: IDragonwellVersions[] = [];
|
||||
|
||||
for (const majorVersion in dragonwellVersions) {
|
||||
const majorVersionMap = dragonwellVersions[majorVersion];
|
||||
for (let jdkVersion in majorVersionMap) {
|
||||
const jdkVersionMap = majorVersionMap[jdkVersion];
|
||||
if (!(platform in jdkVersionMap)) {
|
||||
continue;
|
||||
}
|
||||
const platformMap = jdkVersionMap[platform];
|
||||
if (!(arch in platformMap)) {
|
||||
continue;
|
||||
}
|
||||
const archMap = platformMap[arch];
|
||||
|
||||
if (jdkVersion === 'latest') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Some version of Dragonwell JDK are numerated with help of non-semver notation (more then 3 digits).
|
||||
// Common practice is to transform excess digits to the so-called semver build part, which is prefixed with the plus sign, to be able to operate with them using semver tools.
|
||||
if (jdkVersion.split('.').length > 3) {
|
||||
jdkVersion = convertVersionToSemver(jdkVersion);
|
||||
}
|
||||
|
||||
for (const edition in archMap) {
|
||||
eligibleVersions.push({
|
||||
os: platform,
|
||||
architecture: arch,
|
||||
jdk_version: jdkVersion,
|
||||
checksum: archMap[edition].sha256 ?? '',
|
||||
download_link: archMap[edition].download_url,
|
||||
edition: edition,
|
||||
image_type: 'jdk'
|
||||
});
|
||||
break; // Get the first available link to the JDK. In most cases it should point to the Extended version of JDK, in rare cases like with v17 it points to the Standard version (the only available).
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const sortedVersions = this.sortParsedVersions(eligibleVersions);
|
||||
|
||||
return sortedVersions;
|
||||
}
|
||||
|
||||
// Sorts versions in descending order as by default data in JSON isn't sorted
|
||||
private sortParsedVersions(
|
||||
eligibleVersions: IDragonwellVersions[]
|
||||
): IDragonwellVersions[] {
|
||||
const sortedVersions = eligibleVersions.sort((versionObj1, versionObj2) => {
|
||||
const version1 = versionObj1.jdk_version;
|
||||
const version2 = versionObj2.jdk_version;
|
||||
return semver.compareBuild(version1, version2);
|
||||
});
|
||||
return sortedVersions.reverse();
|
||||
}
|
||||
|
||||
private getPlatformOption(): string {
|
||||
switch (process.platform) {
|
||||
case 'win32':
|
||||
return 'windows';
|
||||
default:
|
||||
return process.platform;
|
||||
}
|
||||
}
|
||||
|
||||
private async fetchJsonFromPrimaryUrl(): Promise<IDragonwellAllVersions | null> {
|
||||
const primaryUrl = 'https://dragonwell-jdk.io/map_with_checksum.json';
|
||||
try {
|
||||
core.debug(
|
||||
`Trying to fetch available Dragonwell versions info from the primary url: ${primaryUrl}`
|
||||
);
|
||||
const fetchedDragonwellJson = (
|
||||
await this.http.getJson<IDragonwellAllVersions>(primaryUrl)
|
||||
).result;
|
||||
return fetchedDragonwellJson;
|
||||
} catch (err) {
|
||||
core.debug(
|
||||
`Fetching Dragonwell versions info from the primary link: ${primaryUrl} ended up with the error: ${err.message}`
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async fetchJsonFromBackupUrl(): Promise<IDragonwellAllVersions | null> {
|
||||
const owner = 'dragonwell-releng';
|
||||
const repository = 'dragonwell-setup-java';
|
||||
const branch = 'main';
|
||||
const filePath = 'releases.json';
|
||||
|
||||
const backupUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
||||
|
||||
const headers = getGitHubHttpHeaders();
|
||||
|
||||
try {
|
||||
core.debug(
|
||||
`Trying to fetch available Dragonwell versions info from the backup url: ${backupUrl}`
|
||||
);
|
||||
const fetchedDragonwellJson = (
|
||||
await this.http.getJson<IDragonwellAllVersions>(backupUrl, headers)
|
||||
).result;
|
||||
return fetchedDragonwellJson;
|
||||
} catch (err) {
|
||||
core.debug(
|
||||
`Fetching Dragonwell versions info from the backup url: ${backupUrl} ended up with the error: ${err.message}`
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
26
src/distributions/dragonwell/models.ts
Normal file
26
src/distributions/dragonwell/models.ts
Normal file
@ -0,0 +1,26 @@
|
||||
export interface IDragonwellAllVersions {
|
||||
[major: string]: {
|
||||
[jdk_version: string]: {
|
||||
[os: string]: {
|
||||
[arch: string]: {
|
||||
[edition: string]: {
|
||||
content_type: string;
|
||||
sha256: string;
|
||||
name: string;
|
||||
download_url: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export interface IDragonwellVersions {
|
||||
os: string;
|
||||
architecture: string;
|
||||
jdk_version: string;
|
||||
checksum: string;
|
||||
download_link: string;
|
||||
edition: string;
|
||||
image_type: string;
|
||||
}
|
@ -4,10 +4,13 @@ import {
|
||||
JavaInstallerOptions,
|
||||
JavaInstallerResults
|
||||
} from '../base-models';
|
||||
import {extractJdkFile, getDownloadArchiveExtension} from '../../util';
|
||||
import {
|
||||
extractJdkFile,
|
||||
getDownloadArchiveExtension,
|
||||
getGitHubHttpHeaders
|
||||
} from '../../util';
|
||||
import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import {OutgoingHttpHeaders} from 'http';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import {ITypedResponse} from '@actions/http-client/interfaces';
|
||||
@ -85,8 +88,6 @@ export class MicrosoftDistributions extends JavaBase {
|
||||
private async getAvailableVersions(): Promise<tc.IToolRelease[] | null> {
|
||||
// TODO get these dynamically!
|
||||
// We will need Microsoft to add an endpoint where we can query for versions.
|
||||
const token = core.getInput('token');
|
||||
const auth = !token ? undefined : `token ${token}`;
|
||||
const owner = 'actions';
|
||||
const repository = 'setup-java';
|
||||
const branch = 'main';
|
||||
@ -96,10 +97,7 @@ export class MicrosoftDistributions extends JavaBase {
|
||||
let releases: tc.IToolRelease[] | null = null;
|
||||
const fileUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
||||
|
||||
const headers: OutgoingHttpHeaders = {
|
||||
authorization: auth,
|
||||
accept: 'application/vnd.github.VERSION.raw'
|
||||
};
|
||||
const headers = getGitHubHttpHeaders();
|
||||
|
||||
let response: ITypedResponse<tc.IToolRelease[]> | null = null;
|
||||
|
||||
|
@ -1,4 +1,41 @@
|
||||
[
|
||||
{
|
||||
"version": "21.0.0",
|
||||
"stable": true,
|
||||
"release_url": "https://aka.ms/download-jdk",
|
||||
"files": [
|
||||
{
|
||||
"filename": "microsoft-jdk-21.0.0-macos-x64.tar.gz",
|
||||
"arch": "x64",
|
||||
"platform": "darwin",
|
||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-macos-x64.tar.gz"
|
||||
},
|
||||
{
|
||||
"filename": "microsoft-jdk-21.0.0-linux-x64.tar.gz",
|
||||
"arch": "x64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-linux-x64.tar.gz"
|
||||
},
|
||||
{
|
||||
"filename": "microsoft-jdk-21.0.0-windows-x64.zip",
|
||||
"arch": "x64",
|
||||
"platform": "win32",
|
||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-windows-x64.zip"
|
||||
},
|
||||
{
|
||||
"filename": "microsoft-jdk-21.0.0-macos-aarch64.tar.gz",
|
||||
"arch": "aarch64",
|
||||
"platform": "darwin",
|
||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-macos-aarch64.tar.gz"
|
||||
},
|
||||
{
|
||||
"filename": "microsoft-jdk-21.0.0-linux-aarch64.tar.gz",
|
||||
"arch": "aarch64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-linux-aarch64.tar.gz"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "17.0.7",
|
||||
"stable": true,
|
||||
|
@ -104,10 +104,10 @@ export function generateToolchainDefinition(
|
||||
} else
|
||||
xmlObj = xmlCreate({
|
||||
toolchains: {
|
||||
'@xmlns': 'https://maven.apache.org/TOOLCHAINS/1.1.0',
|
||||
'@xmlns:xsi': 'https://www.w3.org/2001/XMLSchema-instance',
|
||||
'@xmlns': 'http://maven.apache.org/TOOLCHAINS/1.1.0',
|
||||
'@xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
||||
'@xsi:schemaLocation':
|
||||
'https://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd',
|
||||
'http://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd',
|
||||
toolchain: [
|
||||
{
|
||||
type: 'jdk',
|
||||
|
11
src/util.ts
11
src/util.ts
@ -7,6 +7,7 @@ import * as core from '@actions/core';
|
||||
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import {INPUT_JOB_STATUS, DISTRIBUTIONS_ONLY_MAJOR_VERSION} from './constants';
|
||||
import {OutgoingHttpHeaders} from 'http';
|
||||
|
||||
export function getTempDir() {
|
||||
const tempDirectory = process.env['RUNNER_TEMP'] || os.tmpdir();
|
||||
@ -161,3 +162,13 @@ export function convertVersionToSemver(version: number[] | string) {
|
||||
}
|
||||
return mainVersion;
|
||||
}
|
||||
|
||||
export function getGitHubHttpHeaders(): OutgoingHttpHeaders {
|
||||
const token = core.getInput('token');
|
||||
const auth = !token ? undefined : `token ${token}`;
|
||||
const headers: OutgoingHttpHeaders = {
|
||||
authorization: auth,
|
||||
accept: 'application/vnd.github.VERSION.raw'
|
||||
};
|
||||
return headers;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user