Skip to content

Commit a94f782

Browse files
authored
Merge branch 'main' into dependabot/github_actions/actions/checkout-7
2 parents 7222542 + cefdecd commit a94f782

20 files changed

Lines changed: 317 additions & 81 deletions

.licenses/npm/@actions/cache.dep.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -105,29 +105,27 @@ The `java-version` input supports an exact version or a version range using [Sem
105105

106106
#### Supported distributions
107107
Currently, the following distributions are supported:
108-
| Keyword | Distribution | Official site | License
109-
|-|-|-|-|
110-
| `temurin` | Eclipse Temurin | [Link](https://adoptium.net/) | [Link](https://adoptium.net/about.html)
111-
| `zulu` | Azul Zulu OpenJDK | [Link](https://www.azul.com/downloads/zulu-community/?package=jdk) | [Link](https://www.azul.com/products/zulu-and-zulu-enterprise/zulu-terms-of-use/) |
112-
| `adopt` or `adopt-hotspot` | AdoptOpenJDK Hotspot | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html) |
113-
| `adopt-openj9` | AdoptOpenJDK OpenJ9 | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html) |
114-
| `liberica` | Liberica JDK | [Link](https://bell-sw.com/) | [Link](https://bell-sw.com/liberica_eula/) |
115-
| `microsoft` | Microsoft Build of OpenJDK | [Link](https://www.microsoft.com/openjdk) | [Link](https://docs.microsoft.com/java/openjdk/faq)
116-
| `corretto` | Amazon Corretto Build of OpenJDK | [Link](https://aws.amazon.com/corretto/) | [Link](https://aws.amazon.com/corretto/faqs/)
117-
| `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) |
118-
| `oracle` | Oracle JDK | [Link](https://www.oracle.com/java/technologies/downloads/) | [Link](https://java.com/freeuselicense)
119-
| `dragonwell` | Alibaba Dragonwell JDK | [Link](https://dragonwell-jdk.io/) | [Link](https://www.aliyun.com/product/dragonwell/)
120-
| `sapmachine` | SAP SapMachine JDK/JRE | [Link](https://sapmachine.io/) | [Link](https://github.com/SAP/SapMachine/blob/sapmachine/LICENSE)
121-
| `graalvm` | Oracle GraalVM | [Link](https://www.graalvm.org/) | [Link](https://www.oracle.com/downloads/licenses/graal-free-license.html)
122-
| `jetbrains` | JetBrains Runtime | [Link](https://github.com/JetBrains/JetBrainsRuntime/) | [Link](https://github.com/JetBrains/JetBrainsRuntime/blob/main/LICENSE)
123-
124-
**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.
125-
126-
**NOTE:** 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/).
127-
128-
**NOTE:** For Azul Zulu OpenJDK architectures x64 and arm64 are mapped to x86 / arm with proper hw_bitness.
129-
130-
**NOTE:** 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.
108+
| Keyword | Distribution / Official site | License
109+
|-|-|-|
110+
| `temurin` | [Eclipse Temurin](https://adoptium.net/) | [`temurin` license](https://adoptium.net/about.html)
111+
| `zulu` | [Azul Zulu OpenJDK](https://www.azul.com/downloads/zulu-community/?package=jdk) | [`zulu` license](https://www.azul.com/products/zulu-and-zulu-enterprise/zulu-terms-of-use/) |
112+
| `adopt` or `adopt-hotspot` | [AdoptOpenJDK Hotspot](https://adoptopenjdk.net/) | [`adopt-hotspot` license](https://adoptopenjdk.net/about.html) |
113+
| `adopt-openj9` | [AdoptOpenJDK OpenJ9](https://adoptopenjdk.net/) | [`adopt-openj9` license](https://adoptopenjdk.net/about.html) |
114+
| `liberica` | [Liberica JDK](https://bell-sw.com/) | [`liberica` license](https://bell-sw.com/liberica_eula/) |
115+
| `microsoft` | [Microsoft Build of OpenJDK](https://www.microsoft.com/openjdk) | [`microsoft` license](https://docs.microsoft.com/java/openjdk/faq)
116+
| `corretto` | [Amazon Corretto Build of OpenJDK](https://aws.amazon.com/corretto/) | [`corretto` license](https://aws.amazon.com/corretto/faqs/)
117+
| `semeru` | [IBM Semeru Runtime Open Edition](https://developer.ibm.com/languages/java/semeru-runtimes/downloads/) | [`semeru` license](https://openjdk.java.net/legal/gplv2+ce.html) |
118+
| `oracle` | [Oracle JDK](https://www.oracle.com/java/technologies/downloads/) | [`oracle` license](https://java.com/freeuselicense)
119+
| `dragonwell` | [Alibaba Dragonwell JDK](https://dragonwell-jdk.io/) | [`dragonwell` license](https://www.aliyun.com/product/dragonwell/)
120+
| `sapmachine` | [SAP SapMachine JDK/JRE](https://sapmachine.io/) | [`sapmachine` license](https://github.com/SAP/SapMachine/blob/sapmachine/LICENSE)
121+
| `graalvm` | [Oracle GraalVM](https://www.graalvm.org/) | [`graalvm` license](https://www.oracle.com/downloads/licenses/graal-free-license.html)
122+
| `jetbrains` | [JetBrains Runtime](https://github.com/JetBrains/JetBrainsRuntime/) | [`jetbrains` license](https://github.com/JetBrains/JetBrainsRuntime/blob/main/LICENSE)
123+
124+
> [!NOTE]
125+
> - 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.
126+
> - 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/).
127+
> - For Azul Zulu OpenJDK architectures x64 and arm64 are mapped to x86 / arm with proper hw_bitness.
128+
> - 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.
131129

132130
**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.
133131

@@ -137,7 +135,7 @@ Currently, the following distributions are supported:
137135
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:
138136

139137
- gradle: `**/*.gradle*`, `**/gradle-wrapper.properties`, `buildSrc/**/Versions.kt`, `buildSrc/**/Dependencies.kt`, `gradle/*.versions.toml`, and `**/versions.properties`
140-
- maven: `**/pom.xml`
138+
- maven: `**/pom.xml` and `**/.mvn/wrapper/maven-wrapper.properties`
141139
- sbt: all sbt build definition files `**/*.sbt`, `**/project/build.properties`, `**/project/**.scala`, `**/project/**.sbt`
142140

143141
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.
@@ -218,7 +216,7 @@ In the basic examples above, the `check-latest` flag defaults to `false`. When s
218216

219217
If `check-latest` is set to `true`, the action first checks if the cached version is the latest one. If the locally cached version is not the most up-to-date, the latest version of Java will be downloaded. Set `check-latest` to `true` if you want the most up-to-date version of Java to always be used. Setting `check-latest` to `true` has performance implications as downloading versions of Java is slower than using cached versions.
220218

221-
For Java distributions that are not cached on Hosted images, `check-latest` always behaves as `true` and downloads Java on-flight. Check out [Hosted Tool Cache](docs/advanced-usage.md#Hosted-Tool-Cache) for more details about pre-cached Java versions.
219+
For Java distributions that are not cached on Hosted images, `check-latest` always behaves as `true` and downloads Java on the fly. Check out [Hosted Tool Cache](docs/advanced-usage.md#Hosted-Tool-Cache) for more details about pre-cached Java versions.
222220

223221

224222
```yaml
@@ -282,6 +280,7 @@ In the example above multiple JDKs are installed for the same job. The result af
282280
- [Alibaba Dragonwell](docs/advanced-usage.md#Alibaba-Dragonwell)
283281
- [SapMachine](docs/advanced-usage.md#SapMachine)
284282
- [GraalVM](docs/advanced-usage.md#GraalVM)
283+
- [JetBrains](docs/advanced-usage.md#JetBrains)
285284
- [Installing custom Java package type](docs/advanced-usage.md#Installing-custom-Java-package-type)
286285
- [Installing custom Java architecture](docs/advanced-usage.md#Installing-custom-Java-architecture)
287286
- [Installing custom Java distribution from local file](docs/advanced-usage.md#Installing-Java-from-local-file)

__tests__/cache.test.ts

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,48 @@ describe('dependency cache', () => {
9696
});
9797

9898
describe('for maven', () => {
99-
it('throws error if no pom.xml found', async () => {
99+
it('throws error if no pom.xml or maven-wrapper.properties found', async () => {
100100
await expect(restore('maven', '')).rejects.toThrow(
101101
`No file in ${projectRoot(
102102
workspace
103-
)} matched to [**/pom.xml], make sure you have checked out the target repository`
103+
)} matched to [**/pom.xml,**/.mvn/wrapper/maven-wrapper.properties], make sure you have checked out the target repository`
104104
);
105105
});
106-
it('downloads cache', async () => {
106+
it('downloads cache based on pom.xml', async () => {
107107
createFile(join(workspace, 'pom.xml'));
108108

109109
await restore('maven', '');
110-
expect(spyCacheRestore).toHaveBeenCalled();
111-
expect(spyGlobHashFiles).toHaveBeenCalledWith('**/pom.xml');
110+
expect(spyCacheRestore).toHaveBeenCalledWith(
111+
[
112+
join(os.homedir(), '.m2', 'repository'),
113+
join(os.homedir(), '.m2', 'wrapper', 'dists')
114+
],
115+
expect.any(String)
116+
);
117+
expect(spyGlobHashFiles).toHaveBeenCalledWith(
118+
'**/pom.xml\n**/.mvn/wrapper/maven-wrapper.properties'
119+
);
120+
expect(spyWarning).not.toHaveBeenCalled();
121+
expect(spyInfo).toHaveBeenCalledWith('maven cache is not found');
122+
});
123+
it('downloads cache based on maven-wrapper.properties', async () => {
124+
createDirectory(join(workspace, '.mvn'));
125+
createDirectory(join(workspace, '.mvn', 'wrapper'));
126+
createFile(
127+
join(workspace, '.mvn', 'wrapper', 'maven-wrapper.properties')
128+
);
129+
130+
await restore('maven', '');
131+
expect(spyCacheRestore).toHaveBeenCalledWith(
132+
[
133+
join(os.homedir(), '.m2', 'repository'),
134+
join(os.homedir(), '.m2', 'wrapper', 'dists')
135+
],
136+
expect.any(String)
137+
);
138+
expect(spyGlobHashFiles).toHaveBeenCalledWith(
139+
'**/pom.xml\n**/.mvn/wrapper/maven-wrapper.properties'
140+
);
112141
expect(spyWarning).not.toHaveBeenCalled();
113142
expect(spyInfo).toHaveBeenCalledWith('maven cache is not found');
114143
});
@@ -291,10 +320,12 @@ describe('dependency cache', () => {
291320
await save('maven');
292321
expect(spyCacheSave).toHaveBeenCalled();
293322
expect(spyWarning).not.toHaveBeenCalled();
294-
expect(spyInfo).toHaveBeenCalled();
295-
expect(spyInfo).toHaveBeenCalledWith(
323+
expect(spyInfo).not.toHaveBeenCalledWith(
296324
expect.stringMatching(/^Cache saved with the key:.*/)
297325
);
326+
expect(spyDebug).toHaveBeenCalledWith(
327+
expect.stringMatching(/^Cache was not saved for the key:.*/)
328+
);
298329
});
299330

300331
it('saves with error from toolkit, should fail workflow', async () => {

__tests__/cleanup-java.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('cleanup', () => {
3939
jest.restoreAllMocks();
4040
});
4141

42-
it('does not fail nor warn even when the save process throws a ReserveCacheError', async () => {
42+
it('does not warn/fail even when the save process throws a ReserveCacheError', async () => {
4343
spyCacheSave.mockImplementation((paths: string[], key: string) =>
4444
Promise.reject(
4545
new cache.ReserveCacheError(

__tests__/data/microsoft.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,49 @@
7979
}
8080
]
8181
},
82+
{
83+
"version": "17.0.18",
84+
"stable": true,
85+
"release_url": "https://aka.ms/download-jdk",
86+
"files": [
87+
{
88+
"filename": "microsoft-jdk-17.0.18-macos-x64.tar.gz",
89+
"arch": "x64",
90+
"platform": "darwin",
91+
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.18-macos-x64.tar.gz"
92+
},
93+
{
94+
"filename": "microsoft-jdk-17.0.18-linux-x64.tar.gz",
95+
"arch": "x64",
96+
"platform": "linux",
97+
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.18-linux-x64.tar.gz"
98+
},
99+
{
100+
"filename": "microsoft-jdk-17.0.18-windows-x64.zip",
101+
"arch": "x64",
102+
"platform": "win32",
103+
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.18-windows-x64.zip"
104+
},
105+
{
106+
"filename": "microsoft-jdk-17.0.18-macos-aarch64.tar.gz",
107+
"arch": "aarch64",
108+
"platform": "darwin",
109+
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.18-macos-aarch64.tar.gz"
110+
},
111+
{
112+
"filename": "microsoft-jdk-17.0.18-linux-aarch64.tar.gz",
113+
"arch": "aarch64",
114+
"platform": "linux",
115+
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.18-linux-aarch64.tar.gz"
116+
},
117+
{
118+
"filename": "microsoft-jdk-17.0.18-windows-aarch64.zip",
119+
"arch": "aarch64",
120+
"platform": "win32",
121+
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.18-windows-aarch64.zip"
122+
}
123+
]
124+
},
82125
{
83126
"version": "17.0.7",
84127
"stable": true,

__tests__/data/zulu-windows.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@
247247
{
248248
"id": 12446,
249249
"url": "https://cdn.azul.com/zulu/bin/zulu17.48.15-ca-jdk17.0.10-windows_aarch64.zip",
250-
"name": "zulu17.48.15-ca-jdk17.0.10-win_aarhc4.zip",
250+
"name": "zulu17.48.15-ca-jdk17.0.10-win_aarch4.zip",
251251
"zulu_version": [17, 48, 15, 0],
252252
"jdk_version": [17, 0, 10, 7]
253253
}

__tests__/distributors/dragonwell-installer.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ describe('getAvailableVersions', () => {
225225
['11', 'macos', 'aarch64'],
226226
['17', 'linux', 'riscv']
227227
])(
228-
'should throw when required version of JDK can not be found in the JSON',
228+
'should throw when required version of JDK cannot be found in the JSON',
229229
async (jdkVersion: string, platform: string, arch: string) => {
230230
const distribution = new DragonwellDistribution({
231231
version: jdkVersion,

__tests__/distributors/local-installer.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ describe('setupJava', () => {
219219
);
220220
});
221221

222-
it('java is resolved from toolcache including Contents/Home on MacOS', async () => {
222+
it('java is resolved from toolcache including Contents/Home on macOS', async () => {
223223
const inputs = {
224224
version: actualJavaVersion,
225225
architecture: 'x86',
@@ -262,7 +262,7 @@ describe('setupJava', () => {
262262
});
263263
});
264264

265-
it('java is unpacked from jdkfile including Contents/Home on MacOS', async () => {
265+
it('java is unpacked from jdkfile including Contents/Home on macOS', async () => {
266266
const inputs = {
267267
version: '11.0.289',
268268
architecture: 'x86',

__tests__/distributors/microsoft-installer.test.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,20 @@ describe('findPackageForDownload', () => {
4545
'https://aka.ms/download-jdk/microsoft-jdk-21.0.0-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
4646
],
4747
[
48-
'17.0.1',
49-
'17.0.1+12.1',
50-
'https://aka.ms/download-jdk/microsoft-jdk-17.0.1.12.1-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
48+
'17.x',
49+
'17.0.18',
50+
'https://aka.ms/download-jdk/microsoft-jdk-17.0.18-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
5151
],
5252
[
53-
'17.x',
53+
'17.0.7',
5454
'17.0.7',
5555
'https://aka.ms/download-jdk/microsoft-jdk-17.0.7-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
5656
],
57+
[
58+
'17.0.1',
59+
'17.0.1+12.1',
60+
'https://aka.ms/download-jdk/microsoft-jdk-17.0.1.12.1-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
61+
],
5762
[
5863
'16.0.x',
5964
'16.0.2+7.1',
@@ -119,7 +124,7 @@ describe('findPackageForDownload', () => {
119124
});
120125

121126
const result = await distro['findPackageForDownload'](version);
122-
const expectedUrl = `https://aka.ms/download-jdk/microsoft-jdk-17.0.7-macos-${distroArch}.tar.gz`;
127+
const expectedUrl = `https://aka.ms/download-jdk/microsoft-jdk-17.0.18-macos-${distroArch}.tar.gz`;
123128

124129
expect(result.url).toBe(expectedUrl);
125130
}
@@ -145,7 +150,7 @@ describe('findPackageForDownload', () => {
145150
});
146151

147152
const result = await distro['findPackageForDownload'](version);
148-
const expectedUrl = `https://aka.ms/download-jdk/microsoft-jdk-17.0.7-linux-${distroArch}.tar.gz`;
153+
const expectedUrl = `https://aka.ms/download-jdk/microsoft-jdk-17.0.18-linux-${distroArch}.tar.gz`;
149154

150155
expect(result.url).toBe(expectedUrl);
151156
}
@@ -171,7 +176,7 @@ describe('findPackageForDownload', () => {
171176
});
172177

173178
const result = await distro['findPackageForDownload'](version);
174-
const expectedUrl = `https://aka.ms/download-jdk/microsoft-jdk-17.0.7-windows-${distroArch}.zip`;
179+
const expectedUrl = `https://aka.ms/download-jdk/microsoft-jdk-17.0.18-windows-${distroArch}.zip`;
175180

176181
expect(result.url).toBe(expectedUrl);
177182
}

__tests__/distributors/sapmachine-installer.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ describe('getAvailableVersions', () => {
254254
['21.0.3+8-ea', 'linux', 'x64', '21.0.3+8'],
255255
['17', 'linux-muse', 'aarch64']
256256
])(
257-
'should throw when required version of JDK can not be found in the JSON',
257+
'should throw when required version of JDK cannot be found in the JSON',
258258
async (
259259
version: string,
260260
platform: string,

0 commit comments

Comments
 (0)