mirror of
https://github.com/actions/setup-java.git
synced 2026-11-21 03:43:05 +00:00
Compare commits
9 Commits
copilot/fi
...
07cf016d91
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07cf016d91 | ||
|
|
6cd4d8602a | ||
|
|
ec868c0274 | ||
|
|
90f45856e1 | ||
|
|
7b72cee2af | ||
|
|
49af9112b2 | ||
|
|
66cc98638d | ||
|
|
ac3a4a8d4b | ||
|
|
bc6a9b1b01 |
33
.github/workflows/e2e-versions.yml
vendored
33
.github/workflows/e2e-versions.yml
vendored
@@ -37,8 +37,7 @@ jobs:
|
|||||||
'dragonwell',
|
'dragonwell',
|
||||||
'sapmachine',
|
'sapmachine',
|
||||||
'jetbrains',
|
'jetbrains',
|
||||||
'kona',
|
'kona'
|
||||||
'liberica-nik'
|
|
||||||
] # internally 'adopt-hotspot' is the same as 'adopt'
|
] # internally 'adopt-hotspot' is the same as 'adopt'
|
||||||
version: ['21', '11', '17']
|
version: ['21', '11', '17']
|
||||||
exclude:
|
exclude:
|
||||||
@@ -65,15 +64,6 @@ jobs:
|
|||||||
- distribution: kona
|
- distribution: kona
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
version: 25
|
version: 25
|
||||||
- distribution: liberica-nik
|
|
||||||
os: windows-latest
|
|
||||||
version: 25
|
|
||||||
- distribution: liberica-nik
|
|
||||||
os: ubuntu-latest
|
|
||||||
version: 25
|
|
||||||
- distribution: liberica-nik
|
|
||||||
os: macos-latest
|
|
||||||
version: 25
|
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
os: macos-15-intel
|
os: macos-15-intel
|
||||||
version: 17
|
version: 17
|
||||||
@@ -460,10 +450,6 @@ jobs:
|
|||||||
java-package: jre+fx
|
java-package: jre+fx
|
||||||
version: '11'
|
version: '11'
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
- distribution: 'liberica-nik'
|
|
||||||
java-package: jdk+fx
|
|
||||||
version: '21'
|
|
||||||
os: ubuntu-latest
|
|
||||||
- distribution: 'corretto'
|
- distribution: 'corretto'
|
||||||
java-package: jre
|
java-package: jre
|
||||||
version: '8'
|
version: '8'
|
||||||
@@ -722,12 +708,10 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Verify JAVA_HOME still points to Java 17
|
- name: Verify JAVA_HOME still points to Java 17
|
||||||
env:
|
|
||||||
JAVA_17_PATH: ${{ steps.setup-java-17.outputs.path }}
|
|
||||||
run: |
|
run: |
|
||||||
echo "JAVA_HOME=$JAVA_HOME"
|
echo "JAVA_HOME=$JAVA_HOME"
|
||||||
echo "Java 17 path=$JAVA_17_PATH"
|
echo "Java 17 path=${{ steps.setup-java-17.outputs.path }}"
|
||||||
if [ "$JAVA_HOME" != "$JAVA_17_PATH" ]; then
|
if [ "$JAVA_HOME" != "${{ steps.setup-java-17.outputs.path }}" ]; then
|
||||||
echo "JAVA_HOME should still point to Java 17"
|
echo "JAVA_HOME should still point to Java 17"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -756,17 +740,14 @@ jobs:
|
|||||||
Write-Host "$envName=$JavaVersionPath"
|
Write-Host "$envName=$JavaVersionPath"
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
- name: Verify Java 21 outputs are set
|
- name: Verify Java 21 outputs are set
|
||||||
env:
|
|
||||||
JAVA_21_PATH: ${{ steps.setup-java-21.outputs.path }}
|
|
||||||
JAVA_21_VERSION: ${{ steps.setup-java-21.outputs.version }}
|
|
||||||
run: |
|
run: |
|
||||||
echo "Java 21 path=$JAVA_21_PATH"
|
echo "Java 21 path=${{ steps.setup-java-21.outputs.path }}"
|
||||||
echo "Java 21 version=$JAVA_21_VERSION"
|
echo "Java 21 version=${{ steps.setup-java-21.outputs.version }}"
|
||||||
if [ -z "$JAVA_21_PATH" ]; then
|
if [ -z "${{ steps.setup-java-21.outputs.path }}" ]; then
|
||||||
echo "Java 21 path output should be set"
|
echo "Java 21 path output should be set"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ -z "$JAVA_21_VERSION" ]; then
|
if [ -z "${{ steps.setup-java-21.outputs.version }}" ]; then
|
||||||
echo "Java 21 version output should be set"
|
echo "Java 21 version output should be set"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -124,7 +124,6 @@ Currently, the following distributions are supported:
|
|||||||
| `adopt` or `adopt-hotspot` | [AdoptOpenJDK Hotspot](https://adoptopenjdk.net/) | [`adopt-hotspot` license](https://adoptopenjdk.net/about.html) |
|
| `adopt` or `adopt-hotspot` | [AdoptOpenJDK Hotspot](https://adoptopenjdk.net/) | [`adopt-hotspot` license](https://adoptopenjdk.net/about.html) |
|
||||||
| `adopt-openj9` | [AdoptOpenJDK OpenJ9](https://adoptopenjdk.net/) | [`adopt-openj9` license](https://adoptopenjdk.net/about.html) |
|
| `adopt-openj9` | [AdoptOpenJDK OpenJ9](https://adoptopenjdk.net/) | [`adopt-openj9` license](https://adoptopenjdk.net/about.html) |
|
||||||
| `liberica` | [Liberica JDK](https://bell-sw.com/) | [`liberica` license](https://bell-sw.com/liberica_eula/) |
|
| `liberica` | [Liberica JDK](https://bell-sw.com/) | [`liberica` license](https://bell-sw.com/liberica_eula/) |
|
||||||
| `liberica-nik` | [Liberica Native Image Kit](https://bell-sw.com/pages/downloads/native-image-kit/) | [`liberica-nik` license](https://bell-sw.com/liberica_nik_eula/) |
|
|
||||||
| `microsoft` | [Microsoft Build of OpenJDK](https://www.microsoft.com/openjdk) | [`microsoft` license](https://docs.microsoft.com/java/openjdk/faq)
|
| `microsoft` | [Microsoft Build of OpenJDK](https://www.microsoft.com/openjdk) | [`microsoft` license](https://docs.microsoft.com/java/openjdk/faq)
|
||||||
| `corretto` | [Amazon Corretto Build of OpenJDK](https://aws.amazon.com/corretto/) | [`corretto` license](https://aws.amazon.com/corretto/faqs/)
|
| `corretto` | [Amazon Corretto Build of OpenJDK](https://aws.amazon.com/corretto/) | [`corretto` license](https://aws.amazon.com/corretto/faqs/)
|
||||||
| `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) |
|
| `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) |
|
||||||
@@ -163,7 +162,7 @@ The workflow output `cache-primary-key` exposes the primary cache key computed b
|
|||||||
|
|
||||||
The cache input is optional, and caching is turned off by default.
|
The cache input is optional, and caching is turned off by default.
|
||||||
|
|
||||||
**Maven Wrapper:** when `cache: 'maven'` is enabled, the action also caches and restores the Maven Wrapper distribution downloaded to `~/.m2/wrapper/dists` (in addition to the local repository), so wrapper-based (`./mvnw`) builds don't re-download the wrapper on every run. This is keyed on `**/.mvn/wrapper/maven-wrapper.properties` as shown above.
|
**Maven Wrapper:** when `cache: 'maven'` is enabled, the action also caches and restores the Maven Wrapper distribution downloaded to `~/.m2/wrapper/dists` (in addition to the local repository), so wrapper-based (`./mvnw`) builds don't re-download the Maven distribution. The wrapper distribution is stored in a **separate** cache entry keyed only on `**/.mvn/wrapper/maven-wrapper.properties`, so it stays cached across the frequent `pom.xml` changes that rotate the main dependency cache key.
|
||||||
|
|
||||||
#### Caching gradle dependencies
|
#### Caching gradle dependencies
|
||||||
```yaml
|
```yaml
|
||||||
@@ -181,6 +180,8 @@ steps:
|
|||||||
```
|
```
|
||||||
Using the `cache: gradle` provides a simple and effective way to cache Gradle dependencies with minimal configuration.
|
Using the `cache: gradle` provides a simple and effective way to cache Gradle dependencies with minimal configuration.
|
||||||
|
|
||||||
|
**Gradle Wrapper:** when `cache: 'gradle'` is enabled, the action also caches and restores the Gradle Wrapper distribution downloaded to `~/.gradle/wrapper` (in addition to the Gradle caches), so wrapper-based (`./gradlew`) builds don't re-download the Gradle distribution. The wrapper distribution is stored in a **separate** cache entry keyed only on `**/gradle-wrapper.properties`, so it stays cached across the frequent `*.gradle*` changes that rotate the main dependency cache key.
|
||||||
|
|
||||||
For projects that require more advanced `Gradle` caching features, such as caching build outputs, support for Gradle configuration cache, encrypted cache storage, fine-grained cache control (including options to enable or disable the cache, set it to read-only or write-only, perform automated cleanup, and define custom cache rules), or optimized performance for complex CI workflows, consider using [`gradle/actions/setup-gradle`](https://github.com/gradle/actions/tree/main/setup-gradle).
|
For projects that require more advanced `Gradle` caching features, such as caching build outputs, support for Gradle configuration cache, encrypted cache storage, fine-grained cache control (including options to enable or disable the cache, set it to read-only or write-only, perform automated cleanup, and define custom cache rules), or optimized performance for complex CI workflows, consider using [`gradle/actions/setup-gradle`](https://github.com/gradle/actions/tree/main/setup-gradle).
|
||||||
|
|
||||||
For setup details and a comprehensive overview of all available features, visit the [setup-gradle documentation](https://github.com/gradle/actions/blob/main/docs/setup-gradle.md).
|
For setup details and a comprehensive overview of all available features, visit the [setup-gradle documentation](https://github.com/gradle/actions/blob/main/docs/setup-gradle.md).
|
||||||
@@ -302,7 +303,6 @@ In the example above multiple JDKs are installed for the same job. The result af
|
|||||||
- [Adopt](docs/advanced-usage.md#Adopt)
|
- [Adopt](docs/advanced-usage.md#Adopt)
|
||||||
- [Zulu](docs/advanced-usage.md#Zulu)
|
- [Zulu](docs/advanced-usage.md#Zulu)
|
||||||
- [Liberica](docs/advanced-usage.md#Liberica)
|
- [Liberica](docs/advanced-usage.md#Liberica)
|
||||||
- [Liberica Native Image Kit](docs/advanced-usage.md#Liberica-Native-Image-Kit)
|
|
||||||
- [Microsoft](docs/advanced-usage.md#Microsoft)
|
- [Microsoft](docs/advanced-usage.md#Microsoft)
|
||||||
- [Amazon Corretto](docs/advanced-usage.md#Amazon-Corretto)
|
- [Amazon Corretto](docs/advanced-usage.md#Amazon-Corretto)
|
||||||
- [Oracle](docs/advanced-usage.md#Oracle)
|
- [Oracle](docs/advanced-usage.md#Oracle)
|
||||||
|
|||||||
@@ -166,10 +166,7 @@ describe('dependency cache', () => {
|
|||||||
|
|
||||||
await restore('maven', '');
|
await restore('maven', '');
|
||||||
expect(spyCacheRestore).toHaveBeenCalledWith(
|
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||||
[
|
[join(os.homedir(), '.m2', 'repository')],
|
||||||
join(os.homedir(), '.m2', 'repository'),
|
|
||||||
join(os.homedir(), '.m2', 'wrapper', 'dists')
|
|
||||||
],
|
|
||||||
expect.any(String)
|
expect.any(String)
|
||||||
);
|
);
|
||||||
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||||
@@ -196,10 +193,7 @@ describe('dependency cache', () => {
|
|||||||
|
|
||||||
await restore('maven', '');
|
await restore('maven', '');
|
||||||
expect(spyCacheRestore).toHaveBeenCalledWith(
|
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||||
[
|
[join(os.homedir(), '.m2', 'repository')],
|
||||||
join(os.homedir(), '.m2', 'repository'),
|
|
||||||
join(os.homedir(), '.m2', 'wrapper', 'dists')
|
|
||||||
],
|
|
||||||
expect.any(String)
|
expect.any(String)
|
||||||
);
|
);
|
||||||
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||||
@@ -214,10 +208,7 @@ describe('dependency cache', () => {
|
|||||||
|
|
||||||
await restore('maven', '');
|
await restore('maven', '');
|
||||||
expect(spyCacheRestore).toHaveBeenCalledWith(
|
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||||
[
|
[join(os.homedir(), '.m2', 'repository')],
|
||||||
join(os.homedir(), '.m2', 'repository'),
|
|
||||||
join(os.homedir(), '.m2', 'wrapper', 'dists')
|
|
||||||
],
|
|
||||||
expect.any(String)
|
expect.any(String)
|
||||||
);
|
);
|
||||||
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||||
@@ -226,6 +217,47 @@ describe('dependency cache', () => {
|
|||||||
expect(spyWarning).not.toHaveBeenCalled();
|
expect(spyWarning).not.toHaveBeenCalled();
|
||||||
expect(spyInfo).toHaveBeenCalledWith('maven cache is not found');
|
expect(spyInfo).toHaveBeenCalledWith('maven cache is not found');
|
||||||
});
|
});
|
||||||
|
it('restores the maven wrapper distribution cache independently of the main cache', async () => {
|
||||||
|
createDirectory(join(workspace, '.mvn'));
|
||||||
|
createDirectory(join(workspace, '.mvn', 'wrapper'));
|
||||||
|
createFile(
|
||||||
|
join(workspace, '.mvn', 'wrapper', 'maven-wrapper.properties')
|
||||||
|
);
|
||||||
|
|
||||||
|
await restore('maven', '');
|
||||||
|
// Main dependency cache no longer carries the wrapper dists path.
|
||||||
|
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.m2', 'repository')],
|
||||||
|
expect.any(String)
|
||||||
|
);
|
||||||
|
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.m2', 'wrapper', 'dists')],
|
||||||
|
expect.stringContaining('maven-wrapper')
|
||||||
|
);
|
||||||
|
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||||
|
'**/.mvn/wrapper/maven-wrapper.properties'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('skips the maven wrapper cache when no wrapper properties exist', async () => {
|
||||||
|
createFile(join(workspace, 'pom.xml'));
|
||||||
|
spyGlobHashFiles.mockImplementation((pattern: string) =>
|
||||||
|
Promise.resolve(
|
||||||
|
pattern === '**/.mvn/wrapper/maven-wrapper.properties'
|
||||||
|
? ''
|
||||||
|
: 'hash-stub'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
await restore('maven', '');
|
||||||
|
// Only the main dependency cache is restored; the wrapper cache path is
|
||||||
|
// never touched because the project does not use mvnw.
|
||||||
|
expect(spyCacheRestore).toHaveBeenCalledTimes(1);
|
||||||
|
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.m2', 'repository')],
|
||||||
|
expect.any(String)
|
||||||
|
);
|
||||||
|
expect(spyWarning).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('for gradle', () => {
|
describe('for gradle', () => {
|
||||||
it('throws error if no build.gradle found', async () => {
|
it('throws error if no build.gradle found', async () => {
|
||||||
@@ -282,6 +314,43 @@ describe('dependency cache', () => {
|
|||||||
expect(spyWarning).not.toHaveBeenCalled();
|
expect(spyWarning).not.toHaveBeenCalled();
|
||||||
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
|
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
|
||||||
});
|
});
|
||||||
|
it('restores the gradle wrapper distribution cache independently of the main cache', async () => {
|
||||||
|
createFile(join(workspace, 'build.gradle'));
|
||||||
|
|
||||||
|
await restore('gradle', '');
|
||||||
|
// Main dependency cache no longer carries the wrapper path.
|
||||||
|
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.gradle', 'caches')],
|
||||||
|
expect.any(String)
|
||||||
|
);
|
||||||
|
// Wrapper distribution is restored on its own, keyed only on the
|
||||||
|
// wrapper properties file.
|
||||||
|
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.gradle', 'wrapper')],
|
||||||
|
expect.stringContaining('setup-java-')
|
||||||
|
);
|
||||||
|
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||||
|
'**/gradle-wrapper.properties'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('skips the gradle wrapper cache when no wrapper properties exist', async () => {
|
||||||
|
createFile(join(workspace, 'build.gradle'));
|
||||||
|
spyGlobHashFiles.mockImplementation((pattern: string) =>
|
||||||
|
Promise.resolve(
|
||||||
|
pattern === '**/gradle-wrapper.properties' ? '' : 'hash-stub'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
await restore('gradle', '');
|
||||||
|
// Only the main dependency cache is restored; the wrapper cache path is
|
||||||
|
// never touched because the project does not use the gradle wrapper.
|
||||||
|
expect(spyCacheRestore).toHaveBeenCalledTimes(1);
|
||||||
|
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.gradle', 'caches')],
|
||||||
|
expect.any(String)
|
||||||
|
);
|
||||||
|
expect(spyWarning).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('for sbt', () => {
|
describe('for sbt', () => {
|
||||||
it('throws error if no build.sbt found', async () => {
|
it('throws error if no build.sbt found', async () => {
|
||||||
@@ -457,6 +526,77 @@ describe('dependency cache', () => {
|
|||||||
expect.stringMatching(/^Cache saved with the key:.*/)
|
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('saves the maven wrapper distribution cache under its own key', async () => {
|
||||||
|
createFile(join(workspace, 'pom.xml'));
|
||||||
|
(core.getState as jest.Mock<any>).mockImplementation((name: any) => {
|
||||||
|
switch (name) {
|
||||||
|
case 'cache-primary-key':
|
||||||
|
return 'setup-java-cache-primary-key';
|
||||||
|
case 'cache-matched-key':
|
||||||
|
return 'setup-java-cache-matched-key';
|
||||||
|
case 'cache-primary-key-maven-wrapper':
|
||||||
|
return 'setup-java-maven-wrapper-key';
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await save('maven');
|
||||||
|
expect(spyCacheSave).toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.m2', 'wrapper', 'dists')],
|
||||||
|
'setup-java-maven-wrapper-key'
|
||||||
|
);
|
||||||
|
expect(spyWarning).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
it('does not save the maven wrapper cache on an exact wrapper hit', async () => {
|
||||||
|
createFile(join(workspace, 'pom.xml'));
|
||||||
|
(core.getState as jest.Mock<any>).mockImplementation((name: any) => {
|
||||||
|
switch (name) {
|
||||||
|
case 'cache-primary-key':
|
||||||
|
return 'setup-java-cache-primary-key';
|
||||||
|
case 'cache-matched-key':
|
||||||
|
return 'setup-java-cache-matched-key';
|
||||||
|
case 'cache-primary-key-maven-wrapper':
|
||||||
|
case 'cache-matched-key-maven-wrapper':
|
||||||
|
return 'setup-java-maven-wrapper-key';
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await save('maven');
|
||||||
|
expect(spyCacheSave).not.toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.m2', 'wrapper', 'dists')],
|
||||||
|
expect.any(String)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('does not fail the post step when the wrapper distribution path is missing', async () => {
|
||||||
|
createFile(join(workspace, 'pom.xml'));
|
||||||
|
(core.getState as jest.Mock<any>).mockImplementation((name: any) => {
|
||||||
|
switch (name) {
|
||||||
|
case 'cache-primary-key':
|
||||||
|
return 'setup-java-cache-primary-key';
|
||||||
|
case 'cache-matched-key':
|
||||||
|
return 'setup-java-cache-matched-key';
|
||||||
|
case 'cache-primary-key-maven-wrapper':
|
||||||
|
return 'setup-java-maven-wrapper-key';
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
spyCacheSave.mockImplementation((paths: string[]) =>
|
||||||
|
paths.includes(join(os.homedir(), '.m2', 'wrapper', 'dists'))
|
||||||
|
? Promise.reject(
|
||||||
|
new cache.ValidationError(
|
||||||
|
'Path Validation Error: Path(s) specified in the action for caching do(es) not exist'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
: Promise.resolve(0)
|
||||||
|
);
|
||||||
|
|
||||||
|
await expect(save('maven')).resolves.toBeUndefined();
|
||||||
|
expect(spyWarning).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('for gradle', () => {
|
describe('for gradle', () => {
|
||||||
it('uploads cache even if no build.gradle found', async () => {
|
it('uploads cache even if no build.gradle found', async () => {
|
||||||
@@ -509,6 +649,50 @@ describe('dependency cache', () => {
|
|||||||
expect.stringMatching(/^Cache saved with the key:.*/)
|
expect.stringMatching(/^Cache saved with the key:.*/)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('saves the gradle wrapper distribution cache under its own key', async () => {
|
||||||
|
createFile(join(workspace, 'build.gradle'));
|
||||||
|
(core.getState as jest.Mock<any>).mockImplementation((name: any) => {
|
||||||
|
switch (name) {
|
||||||
|
case 'cache-primary-key':
|
||||||
|
return 'setup-java-cache-primary-key';
|
||||||
|
case 'cache-matched-key':
|
||||||
|
return 'setup-java-cache-matched-key';
|
||||||
|
case 'cache-primary-key-gradle-wrapper':
|
||||||
|
return 'setup-java-gradle-wrapper-key';
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await save('gradle');
|
||||||
|
expect(spyCacheSave).toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.gradle', 'wrapper')],
|
||||||
|
'setup-java-gradle-wrapper-key'
|
||||||
|
);
|
||||||
|
expect(spyWarning).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
it('does not save the gradle wrapper cache on an exact wrapper hit', async () => {
|
||||||
|
createFile(join(workspace, 'build.gradle'));
|
||||||
|
(core.getState as jest.Mock<any>).mockImplementation((name: any) => {
|
||||||
|
switch (name) {
|
||||||
|
case 'cache-primary-key':
|
||||||
|
return 'setup-java-cache-primary-key';
|
||||||
|
case 'cache-matched-key':
|
||||||
|
return 'setup-java-cache-matched-key';
|
||||||
|
case 'cache-primary-key-gradle-wrapper':
|
||||||
|
case 'cache-matched-key-gradle-wrapper':
|
||||||
|
return 'setup-java-gradle-wrapper-key';
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await save('gradle');
|
||||||
|
expect(spyCacheSave).not.toHaveBeenCalledWith(
|
||||||
|
[join(os.homedir(), '.gradle', 'wrapper')],
|
||||||
|
expect.any(String)
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('for sbt', () => {
|
describe('for sbt', () => {
|
||||||
it('uploads cache even if no build.sbt found', async () => {
|
it('uploads cache even if no build.sbt found', async () => {
|
||||||
|
|||||||
@@ -1,739 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/25.0.1+3-25.0.1+16/bellsoft-liberica-vm-openjdk25.0.1+16-25.0.1+3-linux-amd64.tar.gz",
|
|
||||||
"version": "25.0.1+3",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "25.0.1+16",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.1.0+1-23+38/bellsoft-liberica-vm-openjdk23+38-24.1.0+1-linux-amd64.tar.gz",
|
|
||||||
"version": "24.1.0+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "23+38",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.2/bellsoft-liberica-vm-openjdk11.0.15.1+2-21.3.2+2-linux-amd64.tar.gz",
|
|
||||||
"version": "21.3.2+2",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "11.0.15.1+2",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.0/bellsoft-liberica-vm-openjdk17.0.5+8-22.3.0+2-linux-amd64.tar.gz",
|
|
||||||
"version": "22.3.0+2",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.5+8",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.9+1-17.0.16+13/bellsoft-liberica-vm-openjdk17.0.16+13-23.0.9+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.0.9+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.16+13",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/23.0.0/bellsoft-liberica-vm-openjdk17.0.7+7-23.0.0+1-src.tar.gz",
|
|
||||||
"version": "23.0.0+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.7+7",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/25.0.2+1-25.0.2+13/bellsoft-liberica-vm-openjdk25.0.2+13-25.0.2+1-linux-amd64.tar.gz",
|
|
||||||
"version": "25.0.2+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "25.0.2+13",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.1.1+1-23.0.1+13/bellsoft-liberica-vm-openjdk23.0.1+13-24.1.1+1-linux-amd64.tar.gz",
|
|
||||||
"version": "24.1.1+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "23.0.1+13",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.12+1-17.0.19+12/bellsoft-liberica-vm-openjdk17.0.19+12-23.0.12+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.0.12+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.19+12",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.3+1-17.0.10+13/bellsoft-liberica-vm-openjdk17.0.10+13-23.0.3+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.0.3+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.10+13",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.2/bellsoft-liberica-vm-openjdk11-21.3.2-src.tar.gz",
|
|
||||||
"version": "21.3.2+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "11.0.15+10",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.3/bellsoft-liberica-vm-openjdk11.0.20+8-22.3.3+1-src.tar.gz",
|
|
||||||
"version": "22.3.3+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "11.0.20+8",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.8+1-17.0.15+10/bellsoft-liberica-vm-openjdk17.0.15+10-23.0.8+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.0.8+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.15+10",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.3/bellsoft-liberica-vm-openjdk17.0.4-21.3.3-src.tar.gz",
|
|
||||||
"version": "21.3.3+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.4+8",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.7+1-21.0.7+9/bellsoft-liberica-vm-openjdk21.0.7+9-23.1.7+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.1.7+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "21.0.7+9",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.8+1-21.0.8+13/bellsoft-liberica-vm-openjdk21.0.8+13-23.1.8+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.1.8+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "21.0.8+13",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/21.0.0.2/bellsoft-liberica-vm-openjdk11-21.0.0.2-src.tar.gz",
|
|
||||||
"version": "21.0.0.2",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "11.0.10+9",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/23.0.1/bellsoft-liberica-vm-openjdk17.0.8+7-23.0.1+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.0.1+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.8+7",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.0.0+1-22+37/bellsoft-liberica-vm-openjdk22+37-24.0.0+1-linux-amd64.tar.gz",
|
|
||||||
"version": "24.0.0+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "22+37",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/22.1.0/bellsoft-liberica-vm-openjdk17-22.1.0-src.tar.gz",
|
|
||||||
"version": "22.1.0+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.3+7",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.0.2+1-22.0.2+11/bellsoft-liberica-vm-openjdk22.0.2+11-24.0.2+1-linux-amd64.tar.gz",
|
|
||||||
"version": "24.0.2+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "22.0.2+11",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/23.0.1/bellsoft-liberica-vm-openjdk20.0.2+10-23.0.1+1-src.tar.gz",
|
|
||||||
"version": "23.0.1+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "20.0.2+10",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/23.1.0/bellsoft-liberica-vm-openjdk21+37-23.1.0+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.1.0+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "21+37",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.4+3-21.0.4+9/bellsoft-liberica-vm-openjdk21.0.4+9-23.1.4+3-linux-amd64.tar.gz",
|
|
||||||
"version": "23.1.4+3",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "21.0.4+9",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.3/bellsoft-liberica-vm-openjdk11.0.20.1+1-22.3.3+2-linux-amd64.tar.gz",
|
|
||||||
"version": "22.3.3+2",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "11.0.20.1+1",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.4+1-17.0.11+10/bellsoft-liberica-vm-openjdk17.0.11+10-23.0.4+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.0.4+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.11+10",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.1.2+1-23.0.2+9/bellsoft-liberica-vm-openjdk23.0.2+9-24.1.2+1-linux-amd64.tar.gz",
|
|
||||||
"version": "24.1.2+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "23.0.2+9",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.10+1-17.0.17+12/bellsoft-liberica-vm-openjdk17.0.17+12-23.0.10+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.0.10+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.17+12",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.1/bellsoft-liberica-vm-openjdk11.0.18+10-22.3.1+1-src.tar.gz",
|
|
||||||
"version": "22.3.1+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "11.0.18+10",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/22.0.0.2/bellsoft-liberica-vm-openjdk17-22.0.0.2-src.tar.gz",
|
|
||||||
"version": "22.0.0.2",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.2+9",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/22.0.0.2/bellsoft-liberica-vm-openjdk11-22.0.0.2-linux-amd64.tar.gz",
|
|
||||||
"version": "22.0.0.2",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "11.0.14.1+1",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/25.0.1+2-25.0.1+14/bellsoft-liberica-vm-openjdk25.0.1+14-25.0.1+2-linux-amd64.tar.gz",
|
|
||||||
"version": "25.0.1+2",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "25.0.1+14",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.3/bellsoft-liberica-vm-openjdk11.0.16-21.3.3-src.tar.gz",
|
|
||||||
"version": "21.3.3+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "11.0.16+8",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.5+1-21.0.5+11/bellsoft-liberica-vm-openjdk21.0.5+11-23.1.5+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.1.5+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "21.0.5+11",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.4/bellsoft-liberica-vm-openjdk17.0.9+11-22.3.4+1-linux-amd64.tar.gz",
|
|
||||||
"version": "22.3.4+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.9+11",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/25.0.0+1-25+37/bellsoft-liberica-vm-openjdk25+37-25.0.0+1-linux-amd64.tar.gz",
|
|
||||||
"version": "25.0.0+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "25+37",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.3/bellsoft-liberica-vm-openjdk17.0.8.1+1-22.3.3+2-linux-amd64.tar.gz",
|
|
||||||
"version": "22.3.3+2",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.8.1+1",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.3+1-21.0.3+10/bellsoft-liberica-vm-openjdk21.0.3+10-23.1.3+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.1.3+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "21.0.3+10",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.2.0+1-24+37/bellsoft-liberica-vm-openjdk24+37-24.2.0+1-linux-amd64.tar.gz",
|
|
||||||
"version": "24.2.0+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "24+37",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/23.1.1/bellsoft-liberica-vm-openjdk21.0.1+12-23.1.1+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.1.1+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "21.0.1+12",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.3/bellsoft-liberica-vm-openjdk17.0.4.1-21.3.3-src.tar.gz",
|
|
||||||
"version": "21.3.3+2",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.4.1+1",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.11+2-21.0.11+12/bellsoft-liberica-vm-openjdk21.0.11+12-23.1.11+2-linux-amd64.tar.gz",
|
|
||||||
"version": "23.1.11+2",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "21.0.11+12",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.2/bellsoft-liberica-vm-openjdk11.0.19+7-22.3.2+1-src.tar.gz",
|
|
||||||
"version": "22.3.2+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "11.0.19+7",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.4/bellsoft-liberica-vm-openjdk11.0.21+10-22.3.4+1-src.tar.gz",
|
|
||||||
"version": "22.3.4+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "11.0.21+10",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/25.0.3+2-25.0.3+12/bellsoft-liberica-vm-openjdk25.0.3+12-25.0.3+2-linux-amd64.tar.gz",
|
|
||||||
"version": "25.0.3+2",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "25.0.3+12",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.2/bellsoft-liberica-vm-openjdk17.0.3.1+2-21.3.2+2-linux-amd64.tar.gz",
|
|
||||||
"version": "21.3.2+2",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.3.1+2",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.2.1+1-24.0.1+11/bellsoft-liberica-vm-openjdk24.0.1+11-24.2.1+1-linux-amd64.tar.gz",
|
|
||||||
"version": "24.2.1+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "24.0.1+11",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/22.2.0/bellsoft-liberica-vm-openjdk11.0.16.1+1-22.2.0+3-linux-amd64.tar.gz",
|
|
||||||
"version": "22.2.0+3",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "11.0.16.1+1",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.6+1-17.0.13+12/bellsoft-liberica-vm-openjdk17.0.13+12-23.0.6+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.0.6+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.13+12",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/23.0.0/bellsoft-liberica-vm-openjdk20.0.1+10-23.0.0+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.0.0+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "20.0.1+10",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.10+1-21.0.10+11/bellsoft-liberica-vm-openjdk21.0.10+11-23.1.10+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.1.10+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "21.0.10+11",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.1/bellsoft-liberica-vm-openjdk17.0.6+10-22.3.1+1-src.tar.gz",
|
|
||||||
"version": "22.3.1+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.6+10",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.0/bellsoft-liberica-vm-openjdk17-21.3.0-src.tar.gz",
|
|
||||||
"version": "21.3.0",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.1+12",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.0/bellsoft-liberica-vm-openjdk11-21.3.0-src.tar.gz",
|
|
||||||
"version": "21.3.0",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "11.0.13+8",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.0.1+1-22.0.1+10/bellsoft-liberica-vm-openjdk22.0.1+10-24.0.1+1-linux-amd64.tar.gz",
|
|
||||||
"version": "24.0.1+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "22.0.1+10",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.7+1-17.0.14+10/bellsoft-liberica-vm-openjdk17.0.14+10-23.0.7+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.0.7+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.14+10",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/21.1.0/bellsoft-liberica-vm-openjdk11-21.1.0-src.tar.gz",
|
|
||||||
"version": "21.1.0",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "11.0.11+9",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.6+1-21.0.6+10/bellsoft-liberica-vm-openjdk21.0.6+10-23.1.6+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.1.6+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "21.0.6+10",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/25.0.1+1-25.0.1+12/bellsoft-liberica-vm-openjdk25.0.1+12-25.0.1+1-linux-amd64.tar.gz",
|
|
||||||
"version": "25.0.1+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "25.0.1+12",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.9+1-21.0.9+12/bellsoft-liberica-vm-openjdk21.0.9+12-23.1.9+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.1.9+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "21.0.9+12",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/22.3.5+1-11.0.22+12/bellsoft-liberica-vm-openjdk11.0.22+12-22.3.5+1-linux-amd64.tar.gz",
|
|
||||||
"version": "22.3.5+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "11.0.22+12",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.5+1-17.0.12+10/bellsoft-liberica-vm-openjdk17.0.12+10-23.0.5+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.0.5+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.12+10",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.3.1/bellsoft-liberica-vm-openjdk11.0.17+7-21.3.3.1+1-linux-amd64.tar.gz",
|
|
||||||
"version": "21.3.3.1+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "11.0.17+7",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://download.bell-sw.com/vm/21.2.0/bellsoft-liberica-vm-openjdk11-21.2.0-linux-amd64.tar.gz",
|
|
||||||
"version": "21.2.0",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "11.0.12+7",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.11+1-17.0.18+11/bellsoft-liberica-vm-openjdk17.0.18+11-23.0.11+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.0.11+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "17.0.18+11",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.2+1-21.0.2+14/bellsoft-liberica-vm-openjdk21.0.2+14-23.1.2+1-linux-amd64.tar.gz",
|
|
||||||
"version": "23.1.2+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "21.0.2+14",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.2.2+1-24.0.2+13/bellsoft-liberica-vm-openjdk24.0.2+13-24.2.2+1-linux-amd64.tar.gz",
|
|
||||||
"version": "24.2.2+1",
|
|
||||||
"components": [
|
|
||||||
{
|
|
||||||
"component": "liberica",
|
|
||||||
"version": "24.0.2+13",
|
|
||||||
"embedded": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1,219 +0,0 @@
|
|||||||
import {jest, describe, it, expect, beforeEach, afterEach} from '@jest/globals';
|
|
||||||
import type {
|
|
||||||
ArchitectureOptions,
|
|
||||||
NikVersion
|
|
||||||
} from '../../src/distributions/liberica-nik/models.js';
|
|
||||||
import {HttpClient} from '@actions/http-client';
|
|
||||||
|
|
||||||
import manifestData from '../data/liberica-nik.json' with {type: 'json'};
|
|
||||||
|
|
||||||
// Mock @actions/core before importing source modules that depend on it
|
|
||||||
jest.unstable_mockModule('@actions/core', () => ({
|
|
||||||
info: jest.fn(),
|
|
||||||
warning: jest.fn(),
|
|
||||||
debug: jest.fn(),
|
|
||||||
error: jest.fn(),
|
|
||||||
notice: jest.fn(),
|
|
||||||
setFailed: jest.fn(),
|
|
||||||
setOutput: jest.fn(),
|
|
||||||
getInput: jest.fn(),
|
|
||||||
getBooleanInput: jest.fn(),
|
|
||||||
getMultilineInput: jest.fn(),
|
|
||||||
addPath: jest.fn(),
|
|
||||||
exportVariable: jest.fn(),
|
|
||||||
saveState: jest.fn(),
|
|
||||||
getState: jest.fn(),
|
|
||||||
setSecret: jest.fn(),
|
|
||||||
isDebug: jest.fn(() => false),
|
|
||||||
startGroup: jest.fn(),
|
|
||||||
endGroup: jest.fn(),
|
|
||||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
|
||||||
toPlatformPath: jest.fn((p: string) => p),
|
|
||||||
toWin32Path: jest.fn((p: string) => p),
|
|
||||||
toPosixPath: jest.fn((p: string) => p)
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Dynamic imports after mocking
|
|
||||||
const {LibericaNikDistributions} =
|
|
||||||
await import('../../src/distributions/liberica-nik/installer.js');
|
|
||||||
|
|
||||||
const ADDITIONAL_PARAMS =
|
|
||||||
'&installation-type=archive&fields=downloadUrl%2Cversion%2Ccomponents%2Ccomponent%2Cembedded';
|
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
|
||||||
let spyHttpClient: any;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
|
||||||
spyHttpClient.mockReturnValue({
|
|
||||||
statusCode: 200,
|
|
||||||
headers: {},
|
|
||||||
result: manifestData as NikVersion[]
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
jest.resetAllMocks();
|
|
||||||
jest.clearAllMocks();
|
|
||||||
jest.restoreAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
it.each([
|
|
||||||
[
|
|
||||||
{version: '21', architecture: 'x64', packageType: 'jdk'},
|
|
||||||
'bundle-type=standard&bitness=64&arch=x86&build-type=all'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
{version: '21-ea', architecture: 'x64', packageType: 'jdk'},
|
|
||||||
'bundle-type=standard&bitness=64&arch=x86&build-type=ea'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
{version: '21', architecture: 'aarch64', packageType: 'jdk'},
|
|
||||||
'bundle-type=standard&bitness=64&arch=arm&build-type=all'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
{version: '21', architecture: 'x64', packageType: 'jdk+fx'},
|
|
||||||
'bundle-type=full&bitness=64&arch=x86&build-type=all'
|
|
||||||
]
|
|
||||||
])('build correct url for %s -> %s', async (input, urlParams) => {
|
|
||||||
const distribution = new LibericaNikDistributions({
|
|
||||||
...input,
|
|
||||||
checkLatest: false
|
|
||||||
});
|
|
||||||
distribution['getPlatformOption'] = () => 'linux';
|
|
||||||
const buildUrl = `https://api.bell-sw.com/v1/nik/releases?os=linux&${urlParams}${ADDITIONAL_PARAMS}`;
|
|
||||||
|
|
||||||
await distribution['getAvailableVersions']();
|
|
||||||
|
|
||||||
expect(spyHttpClient.mock.calls).toHaveLength(1);
|
|
||||||
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('load available versions', async () => {
|
|
||||||
const distribution = new LibericaNikDistributions({
|
|
||||||
version: '21',
|
|
||||||
architecture: 'x64',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false
|
|
||||||
});
|
|
||||||
const availableVersions = await distribution['getAvailableVersions']();
|
|
||||||
expect(availableVersions).toEqual(manifestData);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getArchitectureOptions', () => {
|
|
||||||
it.each([
|
|
||||||
['x64', {bitness: '64', arch: 'x86'}],
|
|
||||||
['aarch64', {bitness: '64', arch: 'arm'}]
|
|
||||||
] as [string, ArchitectureOptions][])(
|
|
||||||
'parse architecture %s -> %s',
|
|
||||||
(input, expected) => {
|
|
||||||
const distributions = new LibericaNikDistributions({
|
|
||||||
architecture: input,
|
|
||||||
checkLatest: false,
|
|
||||||
packageType: 'jdk',
|
|
||||||
version: '21'
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(distributions['getArchitectureOptions']()).toEqual(expected);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
it.each(['x86', 'armv7', 's390x'])('not support architecture %s', input => {
|
|
||||||
const distributions = new LibericaNikDistributions({
|
|
||||||
architecture: input,
|
|
||||||
checkLatest: false,
|
|
||||||
packageType: 'jdk',
|
|
||||||
version: '21'
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(() => distributions['getArchitectureOptions']()).toThrow(
|
|
||||||
/Architecture '\w+' is not supported\. Supported architectures: .*/
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('findPackageForDownload', () => {
|
|
||||||
let distribution: InstanceType<typeof LibericaNikDistributions>;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
distribution = new LibericaNikDistributions({
|
|
||||||
version: '',
|
|
||||||
architecture: 'x64',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false
|
|
||||||
});
|
|
||||||
distribution['getAvailableVersions'] = async () => manifestData;
|
|
||||||
});
|
|
||||||
|
|
||||||
// The user's java-version resolves against the embedded JDK version, not
|
|
||||||
// NIK's own GraalVM version.
|
|
||||||
it.each([
|
|
||||||
['21', '21.0.11+12'],
|
|
||||||
['17', '17.0.19+12'],
|
|
||||||
['25', '25.0.3+12'],
|
|
||||||
['11', '11.0.22+12'],
|
|
||||||
['21.0.2', '21.0.2+14'],
|
|
||||||
['23', '23.0.2+9'],
|
|
||||||
['20.x', '20.0.2+10'],
|
|
||||||
['25.0.1', '25.0.1+16']
|
|
||||||
])('version is %s -> %s', async (input, expected) => {
|
|
||||||
const result = await distribution['findPackageForDownload'](input);
|
|
||||||
expect(result.version).toBe(expected);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw an error', async () => {
|
|
||||||
await expect(distribution['findPackageForDownload']('7')).rejects.toThrow(
|
|
||||||
/No matching version found for SemVer/
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getPlatformOption', () => {
|
|
||||||
const distributions = new LibericaNikDistributions({
|
|
||||||
architecture: 'x64',
|
|
||||||
version: '21',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false
|
|
||||||
});
|
|
||||||
|
|
||||||
it.each([
|
|
||||||
['linux', 'linux'],
|
|
||||||
['darwin', 'macos'],
|
|
||||||
['win32', 'windows'],
|
|
||||||
['cygwin', 'windows']
|
|
||||||
])('os version %s -> %s', (input, expected) => {
|
|
||||||
const actual = distributions['getPlatformOption'](input as NodeJS.Platform);
|
|
||||||
|
|
||||||
expect(actual).toEqual(expected);
|
|
||||||
});
|
|
||||||
|
|
||||||
it.each(['sunos', 'aix', 'android', 'freebsd'])(
|
|
||||||
'not support os version %s',
|
|
||||||
input => {
|
|
||||||
expect(() =>
|
|
||||||
distributions['getPlatformOption'](input as NodeJS.Platform)
|
|
||||||
).toThrow(/Platform '\w+' is not supported\. Supported platforms: .+/);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('convertVersionToSemver', () => {
|
|
||||||
const distributions = new LibericaNikDistributions({
|
|
||||||
architecture: 'x64',
|
|
||||||
version: '21',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false
|
|
||||||
});
|
|
||||||
|
|
||||||
it.each([
|
|
||||||
['25.0.1+16', '25.0.1+16'],
|
|
||||||
['21+37', '21.0.0+37'],
|
|
||||||
['23+38', '23.0.0+38'],
|
|
||||||
['11.0.15.1+2', '11.0.15+1.2'],
|
|
||||||
['17.0.5', '17.0.5']
|
|
||||||
])('%s -> %s', (input, expected) => {
|
|
||||||
const actual = distributions['convertVersionToSemver'](input);
|
|
||||||
expect(actual).toEqual(expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -86,7 +86,8 @@ describe('toolchains tests', () => {
|
|||||||
|
|
||||||
await toolchains.createToolchainsSettings({
|
await toolchains.createToolchainsSettings({
|
||||||
jdkInfo,
|
jdkInfo,
|
||||||
settingsDirectory: altHome
|
settingsDirectory: altHome,
|
||||||
|
overwriteSettings: true
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(fs.existsSync(m2Dir)).toBe(false);
|
expect(fs.existsSync(m2Dir)).toBe(false);
|
||||||
@@ -134,7 +135,8 @@ describe('toolchains tests', () => {
|
|||||||
|
|
||||||
await toolchains.createToolchainsSettings({
|
await toolchains.createToolchainsSettings({
|
||||||
jdkInfo,
|
jdkInfo,
|
||||||
settingsDirectory: m2Dir
|
settingsDirectory: m2Dir,
|
||||||
|
overwriteSettings: true
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
@@ -215,7 +217,8 @@ describe('toolchains tests', () => {
|
|||||||
|
|
||||||
await toolchains.createToolchainsSettings({
|
await toolchains.createToolchainsSettings({
|
||||||
jdkInfo,
|
jdkInfo,
|
||||||
settingsDirectory: m2Dir
|
settingsDirectory: m2Dir,
|
||||||
|
overwriteSettings: true
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
@@ -300,7 +303,8 @@ describe('toolchains tests', () => {
|
|||||||
|
|
||||||
await toolchains.createToolchainsSettings({
|
await toolchains.createToolchainsSettings({
|
||||||
jdkInfo,
|
jdkInfo,
|
||||||
settingsDirectory: m2Dir
|
settingsDirectory: m2Dir,
|
||||||
|
overwriteSettings: true
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
@@ -377,7 +381,8 @@ describe('toolchains tests', () => {
|
|||||||
|
|
||||||
await toolchains.createToolchainsSettings({
|
await toolchains.createToolchainsSettings({
|
||||||
jdkInfo,
|
jdkInfo,
|
||||||
settingsDirectory: m2Dir
|
settingsDirectory: m2Dir,
|
||||||
|
overwriteSettings: true
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
@@ -447,7 +452,8 @@ describe('toolchains tests', () => {
|
|||||||
|
|
||||||
await toolchains.createToolchainsSettings({
|
await toolchains.createToolchainsSettings({
|
||||||
jdkInfo,
|
jdkInfo,
|
||||||
settingsDirectory: m2Dir
|
settingsDirectory: m2Dir,
|
||||||
|
overwriteSettings: true
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
@@ -539,7 +545,8 @@ describe('toolchains tests', () => {
|
|||||||
|
|
||||||
await toolchains.createToolchainsSettings({
|
await toolchains.createToolchainsSettings({
|
||||||
jdkInfo,
|
jdkInfo,
|
||||||
settingsDirectory: m2Dir
|
settingsDirectory: m2Dir,
|
||||||
|
overwriteSettings: true
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
@@ -598,7 +605,8 @@ describe('toolchains tests', () => {
|
|||||||
|
|
||||||
await toolchains.createToolchainsSettings({
|
await toolchains.createToolchainsSettings({
|
||||||
jdkInfo,
|
jdkInfo,
|
||||||
settingsDirectory: m2Dir
|
settingsDirectory: m2Dir,
|
||||||
|
overwriteSettings: true
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
@@ -656,7 +664,8 @@ describe('toolchains tests', () => {
|
|||||||
|
|
||||||
await toolchains.createToolchainsSettings({
|
await toolchains.createToolchainsSettings({
|
||||||
jdkInfo,
|
jdkInfo,
|
||||||
settingsDirectory: m2Dir
|
settingsDirectory: m2Dir,
|
||||||
|
overwriteSettings: true
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
@@ -739,7 +748,8 @@ describe('toolchains tests', () => {
|
|||||||
|
|
||||||
await toolchains.createToolchainsSettings({
|
await toolchains.createToolchainsSettings({
|
||||||
jdkInfo,
|
jdkInfo,
|
||||||
settingsDirectory: m2Dir
|
settingsDirectory: m2Dir,
|
||||||
|
overwriteSettings: true
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
@@ -818,7 +828,8 @@ describe('toolchains tests', () => {
|
|||||||
|
|
||||||
await toolchains.createToolchainsSettings({
|
await toolchains.createToolchainsSettings({
|
||||||
jdkInfo,
|
jdkInfo,
|
||||||
settingsDirectory: m2Dir
|
settingsDirectory: m2Dir,
|
||||||
|
overwriteSettings: true
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
@@ -843,7 +854,7 @@ describe('toolchains tests', () => {
|
|||||||
).toEqual(result);
|
).toEqual(result);
|
||||||
}, 100000);
|
}, 100000);
|
||||||
|
|
||||||
it('extends existing toolchains.xml files instead of overwriting them', async () => {
|
it('does not overwrite existing toolchains.xml files', async () => {
|
||||||
const jdkInfo = {
|
const jdkInfo = {
|
||||||
version: '17',
|
version: '17',
|
||||||
vendor: 'Eclipse Temurin',
|
vendor: 'Eclipse Temurin',
|
||||||
@@ -872,20 +883,13 @@ describe('toolchains tests', () => {
|
|||||||
|
|
||||||
await toolchains.createToolchainsSettings({
|
await toolchains.createToolchainsSettings({
|
||||||
jdkInfo,
|
jdkInfo,
|
||||||
settingsDirectory: m2Dir
|
settingsDirectory: m2Dir,
|
||||||
|
overwriteSettings: false
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
expect(fs.existsSync(toolchainsFile)).toBe(true);
|
expect(fs.existsSync(toolchainsFile)).toBe(true);
|
||||||
|
expect(fs.readFileSync(toolchainsFile, 'utf-8')).toEqual(originalFile);
|
||||||
const updated = fs.readFileSync(toolchainsFile, 'utf-8');
|
|
||||||
// The pre-existing (Sun 1.6) toolchain must be preserved ...
|
|
||||||
expect(updated).toContain('<id>sun_1.6</id>');
|
|
||||||
expect(updated).toContain('<jdkHome>/opt/jdk/sun/1.6</jdkHome>');
|
|
||||||
// ... and the newly installed JDK must be appended.
|
|
||||||
expect(updated).toContain('<id>temurin_17</id>');
|
|
||||||
expect(updated).toContain('<vendor>Eclipse Temurin</vendor>');
|
|
||||||
expect(updated).toContain(`<jdkHome>${jdkInfo.jdkHome}</jdkHome>`);
|
|
||||||
}, 100000);
|
}, 100000);
|
||||||
|
|
||||||
it('generates valid toolchains.xml with minimal configuration', () => {
|
it('generates valid toolchains.xml with minimal configuration', () => {
|
||||||
@@ -955,55 +959,4 @@ describe('toolchains tests', () => {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}, 100000);
|
}, 100000);
|
||||||
|
|
||||||
it('preserves toolchains from previous executions across multiple setup-java runs', async () => {
|
|
||||||
// Regression test for https://github.com/actions/setup-java/issues/1099
|
|
||||||
// Running setup-java several times in the same job (e.g. multiple steps / multiple
|
|
||||||
// java-version entries) must accumulate every JDK in toolchains.xml rather
|
|
||||||
// than replacing previously registered entries.
|
|
||||||
(core.getInput as jest.Mock<any>).mockImplementation((name: string) => {
|
|
||||||
if (name === 'settings-path') return m2Dir;
|
|
||||||
return '';
|
|
||||||
});
|
|
||||||
|
|
||||||
const runs = [
|
|
||||||
{
|
|
||||||
version: '8',
|
|
||||||
distributionName: 'temurin',
|
|
||||||
id: 'temurin_8',
|
|
||||||
jdkHome: '/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/8.0.1-12/x64'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
version: '11',
|
|
||||||
distributionName: 'temurin',
|
|
||||||
id: 'temurin_11',
|
|
||||||
jdkHome: '/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/11.0.1-12/x64'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
version: '17',
|
|
||||||
distributionName: 'temurin',
|
|
||||||
id: 'temurin_17',
|
|
||||||
jdkHome: '/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64'
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const run of runs) {
|
|
||||||
await toolchains.configureToolchains(
|
|
||||||
run.version,
|
|
||||||
run.distributionName,
|
|
||||||
run.jdkHome,
|
|
||||||
undefined
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(fs.existsSync(toolchainsFile)).toBe(true);
|
|
||||||
const contents = fs.readFileSync(toolchainsFile, 'utf-8');
|
|
||||||
|
|
||||||
for (const run of runs) {
|
|
||||||
expect(contents).toContain(`<id>${run.id}</id>`);
|
|
||||||
expect(contents).toContain(`<jdkHome>${run.jdkHome}</jdkHome>`);
|
|
||||||
}
|
|
||||||
// Exactly one <toolchain> entry per run – no duplicates, none dropped.
|
|
||||||
expect((contents.match(/<toolchain>/g) || []).length).toBe(runs.length);
|
|
||||||
}, 100000);
|
|
||||||
});
|
});
|
||||||
|
|||||||
129
dist/cleanup/index.js
vendored
129
dist/cleanup/index.js
vendored
@@ -99666,23 +99666,28 @@ const CACHE_KEY_PREFIX = 'setup-java';
|
|||||||
const supportedPackageManager = [
|
const supportedPackageManager = [
|
||||||
{
|
{
|
||||||
id: 'maven',
|
id: 'maven',
|
||||||
path: [
|
path: [(0,external_path_.join)(external_os_default().homedir(), '.m2', 'repository')],
|
||||||
(0,external_path_.join)(external_os_default().homedir(), '.m2', 'repository'),
|
|
||||||
(0,external_path_.join)(external_os_default().homedir(), '.m2', 'wrapper', 'dists')
|
|
||||||
],
|
|
||||||
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven
|
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven
|
||||||
pattern: [
|
pattern: [
|
||||||
'**/pom.xml',
|
'**/pom.xml',
|
||||||
'**/.mvn/wrapper/maven-wrapper.properties',
|
'**/.mvn/wrapper/maven-wrapper.properties',
|
||||||
'**/.mvn/extensions.xml'
|
'**/.mvn/extensions.xml'
|
||||||
|
],
|
||||||
|
// The Maven wrapper distribution only depends on the wrapper properties,
|
||||||
|
// which change very rarely, so it is cached separately from the local
|
||||||
|
// repository. This keeps it available across the frequent pom.xml changes
|
||||||
|
// that rotate the main cache key. See issue #1095.
|
||||||
|
additionalCaches: [
|
||||||
|
{
|
||||||
|
name: 'maven-wrapper',
|
||||||
|
path: [(0,external_path_.join)(external_os_default().homedir(), '.m2', 'wrapper', 'dists')],
|
||||||
|
pattern: ['**/.mvn/wrapper/maven-wrapper.properties']
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'gradle',
|
id: 'gradle',
|
||||||
path: [
|
path: [(0,external_path_.join)(external_os_default().homedir(), '.gradle', 'caches')],
|
||||||
(0,external_path_.join)(external_os_default().homedir(), '.gradle', 'caches'),
|
|
||||||
(0,external_path_.join)(external_os_default().homedir(), '.gradle', 'wrapper')
|
|
||||||
],
|
|
||||||
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---gradle
|
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---gradle
|
||||||
pattern: [
|
pattern: [
|
||||||
'**/*.gradle*',
|
'**/*.gradle*',
|
||||||
@@ -99691,6 +99696,17 @@ const supportedPackageManager = [
|
|||||||
'buildSrc/**/Dependencies.kt',
|
'buildSrc/**/Dependencies.kt',
|
||||||
'gradle/*.versions.toml',
|
'gradle/*.versions.toml',
|
||||||
'**/versions.properties'
|
'**/versions.properties'
|
||||||
|
],
|
||||||
|
// The Gradle wrapper distribution only depends on the wrapper properties,
|
||||||
|
// which change very rarely, so it is cached separately from the Gradle
|
||||||
|
// caches. This keeps it available across the frequent *.gradle* changes
|
||||||
|
// that rotate the main cache key. See issue #269.
|
||||||
|
additionalCaches: [
|
||||||
|
{
|
||||||
|
name: 'gradle-wrapper',
|
||||||
|
path: [(0,external_path_.join)(external_os_default().homedir(), '.gradle', 'wrapper')],
|
||||||
|
pattern: ['**/gradle-wrapper.properties']
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -99726,6 +99742,19 @@ function findPackageManager(id) {
|
|||||||
}
|
}
|
||||||
return packageManager;
|
return packageManager;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* State keys used to carry an additional cache's restore-time information over
|
||||||
|
* to the post (save) action, scoped by the additional cache name.
|
||||||
|
*/
|
||||||
|
function additionalCachePrimaryKeyState(name) {
|
||||||
|
return `${STATE_CACHE_PRIMARY_KEY}-${name}`;
|
||||||
|
}
|
||||||
|
function additionalCacheMatchedKeyState(name) {
|
||||||
|
return `${CACHE_MATCHED_KEY}-${name}`;
|
||||||
|
}
|
||||||
|
function buildCacheKey(id, fileHash) {
|
||||||
|
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${id}-${fileHash}`;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* A function that generates a cache key to use.
|
* A function that generates a cache key to use.
|
||||||
* Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"".
|
* Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"".
|
||||||
@@ -99739,7 +99768,19 @@ async function computeCacheKey(packageManager, cacheDependencyPath) {
|
|||||||
if (!fileHash) {
|
if (!fileHash) {
|
||||||
throw new Error(`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`);
|
throw new Error(`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`);
|
||||||
}
|
}
|
||||||
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${packageManager.id}-${fileHash}`;
|
return buildCacheKey(packageManager.id, fileHash);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Computes the cache key for an additional cache. Unlike {@link computeCacheKey}
|
||||||
|
* this returns undefined (instead of throwing) when no file matches the pattern,
|
||||||
|
* because additional caches are optional features that many projects do not use.
|
||||||
|
*/
|
||||||
|
async function computeAdditionalCacheKey(additionalCache) {
|
||||||
|
const fileHash = await glob.hashFiles(additionalCache.pattern.join('\n'));
|
||||||
|
if (!fileHash) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return buildCacheKey(additionalCache.name, fileHash);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Restore the dependency cache
|
* Restore the dependency cache
|
||||||
@@ -99763,6 +99804,29 @@ async function restore(id, cacheDependencyPath) {
|
|||||||
core.setOutput('cache-hit', false);
|
core.setOutput('cache-hit', false);
|
||||||
core.info(`${packageManager.id} cache is not found`);
|
core.info(`${packageManager.id} cache is not found`);
|
||||||
}
|
}
|
||||||
|
for (const additionalCache of packageManager.additionalCaches ?? []) {
|
||||||
|
await restoreAdditionalCache(additionalCache);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Restore an additional cache (e.g. a build-tool wrapper distribution) that is
|
||||||
|
* keyed independently of the main dependency cache so that it survives changes
|
||||||
|
* to volatile dependency files. Skips silently when the project does not use
|
||||||
|
* the corresponding feature.
|
||||||
|
*/
|
||||||
|
async function restoreAdditionalCache(additionalCache) {
|
||||||
|
const primaryKey = await computeAdditionalCacheKey(additionalCache);
|
||||||
|
if (!primaryKey) {
|
||||||
|
core.debug(`No file matched [${additionalCache.pattern}] for the ${additionalCache.name} cache, skipping.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
core.debug(`${additionalCache.name} primary key is ${primaryKey}`);
|
||||||
|
core.saveState(additionalCachePrimaryKeyState(additionalCache.name), primaryKey);
|
||||||
|
const matchedKey = await cache.restoreCache(additionalCache.path, primaryKey);
|
||||||
|
if (matchedKey) {
|
||||||
|
core.saveState(additionalCacheMatchedKeyState(additionalCache.name), matchedKey);
|
||||||
|
core.info(`${additionalCache.name} cache restored from key: ${matchedKey}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Save the dependency cache
|
* Save the dependency cache
|
||||||
@@ -99773,6 +99837,9 @@ async function save(id) {
|
|||||||
const matchedKey = getState(CACHE_MATCHED_KEY);
|
const matchedKey = getState(CACHE_MATCHED_KEY);
|
||||||
// Inputs are re-evaluated before the post action, so we want the original key used for restore
|
// Inputs are re-evaluated before the post action, so we want the original key used for restore
|
||||||
const primaryKey = getState(STATE_CACHE_PRIMARY_KEY);
|
const primaryKey = getState(STATE_CACHE_PRIMARY_KEY);
|
||||||
|
for (const additionalCache of packageManager.additionalCaches ?? []) {
|
||||||
|
await saveAdditionalCache(packageManager, additionalCache);
|
||||||
|
}
|
||||||
if (!primaryKey) {
|
if (!primaryKey) {
|
||||||
warning('Error retrieving key from state.');
|
warning('Error retrieving key from state.');
|
||||||
return;
|
return;
|
||||||
@@ -99807,6 +99874,50 @@ async function save(id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Save an additional cache under its own key. Skips when no key was recorded at
|
||||||
|
* restore time (feature unused) or when the exact key was already restored.
|
||||||
|
*/
|
||||||
|
async function saveAdditionalCache(packageManager, additionalCache) {
|
||||||
|
const primaryKey = getState(additionalCachePrimaryKeyState(additionalCache.name));
|
||||||
|
const matchedKey = getState(additionalCacheMatchedKeyState(additionalCache.name));
|
||||||
|
if (!primaryKey) {
|
||||||
|
// The feature is not used by this project, nothing to save.
|
||||||
|
core_debug(`No primary key for the ${additionalCache.name} cache, not saving cache.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (matchedKey === primaryKey) {
|
||||||
|
info(`Cache hit occurred on the ${additionalCache.name} primary key ${primaryKey}, not saving cache.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const cacheId = await cache_saveCache(additionalCache.path, primaryKey);
|
||||||
|
if (cacheId === -1) {
|
||||||
|
core_debug(`${additionalCache.name} cache was not saved for the key: ${primaryKey}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
info(`${additionalCache.name} cache saved with the key: ${primaryKey}`);
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
const err = error;
|
||||||
|
if (err.name === ValidationError.name) {
|
||||||
|
// The cache paths did not resolve, e.g. the wrapper distribution was
|
||||||
|
// never downloaded because a system build tool was used or the download
|
||||||
|
// failed. Optional wrapper caches must not fail the post step, so skip.
|
||||||
|
core_debug(`${additionalCache.name} cache paths do not exist, not saving cache: ${err.message}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (err.name === ReserveCacheError.name) {
|
||||||
|
info(err.message);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (isProbablyGradleDaemonProblem(packageManager, err)) {
|
||||||
|
warning('Failed to save Gradle cache on Windows. If tar.exe reported "Permission denied", try to run Gradle with `--no-daemon` option. Refer to https://github.com/actions/cache/issues/454 for details.');
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @param packageManager the specified package manager by user
|
* @param packageManager the specified package manager by user
|
||||||
* @param error the error thrown by the saveCache
|
* @param error the error thrown by the saveCache
|
||||||
|
|||||||
293
dist/setup/index.js
vendored
293
dist/setup/index.js
vendored
@@ -38608,7 +38608,7 @@ let h2ExperimentalWarned = false
|
|||||||
/** @type {import('http2')} */
|
/** @type {import('http2')} */
|
||||||
let http2
|
let http2
|
||||||
try {
|
try {
|
||||||
http2 = __nccwpck_require__(2467)
|
http2 = __nccwpck_require__(4848)
|
||||||
} catch {
|
} catch {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
http2 = { constants: {} }
|
http2 = { constants: {} }
|
||||||
@@ -64403,7 +64403,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:http");
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 2467:
|
/***/ 4848:
|
||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:http2");
|
module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:http2");
|
||||||
@@ -127351,11 +127351,13 @@ async function write(directory, settings, overwriteSettings) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function configureToolchains(version, distributionName, jdkHome, toolchainId) {
|
async function configureToolchains(version, distributionName, jdkHome, toolchainId) {
|
||||||
const vendor = getInput(INPUT_MVN_TOOLCHAIN_VENDOR) || distributionName;
|
const vendor = getInput(INPUT_MVN_TOOLCHAIN_VENDOR) || distributionName;
|
||||||
const id = toolchainId || `${vendor}_${version}`;
|
const id = toolchainId || `${vendor}_${version}`;
|
||||||
const settingsDirectory = getInput(INPUT_SETTINGS_PATH) ||
|
const settingsDirectory = getInput(INPUT_SETTINGS_PATH) ||
|
||||||
external_path_.join(external_os_.homedir(), M2_DIR);
|
external_path_.join(external_os_.homedir(), M2_DIR);
|
||||||
|
const overwriteSettings = util_getBooleanInput(INPUT_OVERWRITE_SETTINGS, true);
|
||||||
await createToolchainsSettings({
|
await createToolchainsSettings({
|
||||||
jdkInfo: {
|
jdkInfo: {
|
||||||
version,
|
version,
|
||||||
@@ -127363,17 +127365,18 @@ async function configureToolchains(version, distributionName, jdkHome, toolchain
|
|||||||
id,
|
id,
|
||||||
jdkHome
|
jdkHome
|
||||||
},
|
},
|
||||||
settingsDirectory
|
settingsDirectory,
|
||||||
|
overwriteSettings
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
async function createToolchainsSettings({ jdkInfo, settingsDirectory }) {
|
async function createToolchainsSettings({ jdkInfo, settingsDirectory, overwriteSettings }) {
|
||||||
info(`Creating ${MVN_TOOLCHAINS_FILE} for JDK version ${jdkInfo.version} from ${jdkInfo.vendor}`);
|
info(`Creating ${MVN_TOOLCHAINS_FILE} for JDK version ${jdkInfo.version} from ${jdkInfo.vendor}`);
|
||||||
// when an alternate m2 location is specified use only that location (no .m2 directory)
|
// when an alternate m2 location is specified use only that location (no .m2 directory)
|
||||||
// otherwise use the home/.m2/ path
|
// otherwise use the home/.m2/ path
|
||||||
await mkdirP(settingsDirectory);
|
await mkdirP(settingsDirectory);
|
||||||
const originalToolchains = await readExistingToolchainsFile(settingsDirectory);
|
const originalToolchains = await readExistingToolchainsFile(settingsDirectory);
|
||||||
const updatedToolchains = generateToolchainDefinition(originalToolchains, jdkInfo.version, jdkInfo.vendor, jdkInfo.id, jdkInfo.jdkHome);
|
const updatedToolchains = generateToolchainDefinition(originalToolchains, jdkInfo.version, jdkInfo.vendor, jdkInfo.id, jdkInfo.jdkHome);
|
||||||
await writeToolchainsFileToDisk(settingsDirectory, updatedToolchains);
|
await writeToolchainsFileToDisk(settingsDirectory, updatedToolchains, overwriteSettings);
|
||||||
}
|
}
|
||||||
// only exported for testing purposes
|
// only exported for testing purposes
|
||||||
function generateToolchainDefinition(original, version, vendor, id, jdkHome) {
|
function generateToolchainDefinition(original, version, vendor, id, jdkHome) {
|
||||||
@@ -127455,20 +127458,18 @@ async function readExistingToolchainsFile(directory) {
|
|||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
async function writeToolchainsFileToDisk(directory, settings) {
|
async function writeToolchainsFileToDisk(directory, settings, overwriteSettings) {
|
||||||
const location = external_path_.join(directory, MVN_TOOLCHAINS_FILE);
|
const location = external_path_.join(directory, MVN_TOOLCHAINS_FILE);
|
||||||
const settingsExists = external_fs_namespaceObject.existsSync(location);
|
const settingsExists = external_fs_namespaceObject.existsSync(location);
|
||||||
// The toolchains file is produced by a non-destructive merge (existing JDK,
|
if (settingsExists && overwriteSettings) {
|
||||||
// custom, and non-jdk toolchains are preserved – see generateToolchainDefinition),
|
info(`Overwriting existing file ${location}`);
|
||||||
// so it is always safe to write it. Unlike settings.xml, it is therefore not
|
}
|
||||||
// gated behind the `overwrite-settings` input; that would prevent subsequent
|
else if (!settingsExists) {
|
||||||
// setup-java runs from registering additional JDKs and silently drop the
|
info(`Writing to ${location}`);
|
||||||
// toolchain entries created by earlier runs.
|
|
||||||
if (settingsExists) {
|
|
||||||
info(`Updating existing file ${location}`);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
info(`Writing to ${location}`);
|
info(`Skipping generation of ${location} because file already exists and overwriting is not enabled`);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return external_fs_namespaceObject.writeFileSync(location, settings, {
|
return external_fs_namespaceObject.writeFileSync(location, settings, {
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
@@ -130887,23 +130888,28 @@ const CACHE_KEY_PREFIX = 'setup-java';
|
|||||||
const supportedPackageManager = [
|
const supportedPackageManager = [
|
||||||
{
|
{
|
||||||
id: 'maven',
|
id: 'maven',
|
||||||
path: [
|
path: [(0,external_path_.join)(external_os_default().homedir(), '.m2', 'repository')],
|
||||||
(0,external_path_.join)(external_os_default().homedir(), '.m2', 'repository'),
|
|
||||||
(0,external_path_.join)(external_os_default().homedir(), '.m2', 'wrapper', 'dists')
|
|
||||||
],
|
|
||||||
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven
|
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven
|
||||||
pattern: [
|
pattern: [
|
||||||
'**/pom.xml',
|
'**/pom.xml',
|
||||||
'**/.mvn/wrapper/maven-wrapper.properties',
|
'**/.mvn/wrapper/maven-wrapper.properties',
|
||||||
'**/.mvn/extensions.xml'
|
'**/.mvn/extensions.xml'
|
||||||
|
],
|
||||||
|
// The Maven wrapper distribution only depends on the wrapper properties,
|
||||||
|
// which change very rarely, so it is cached separately from the local
|
||||||
|
// repository. This keeps it available across the frequent pom.xml changes
|
||||||
|
// that rotate the main cache key. See issue #1095.
|
||||||
|
additionalCaches: [
|
||||||
|
{
|
||||||
|
name: 'maven-wrapper',
|
||||||
|
path: [(0,external_path_.join)(external_os_default().homedir(), '.m2', 'wrapper', 'dists')],
|
||||||
|
pattern: ['**/.mvn/wrapper/maven-wrapper.properties']
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'gradle',
|
id: 'gradle',
|
||||||
path: [
|
path: [(0,external_path_.join)(external_os_default().homedir(), '.gradle', 'caches')],
|
||||||
(0,external_path_.join)(external_os_default().homedir(), '.gradle', 'caches'),
|
|
||||||
(0,external_path_.join)(external_os_default().homedir(), '.gradle', 'wrapper')
|
|
||||||
],
|
|
||||||
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---gradle
|
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---gradle
|
||||||
pattern: [
|
pattern: [
|
||||||
'**/*.gradle*',
|
'**/*.gradle*',
|
||||||
@@ -130912,6 +130918,17 @@ const supportedPackageManager = [
|
|||||||
'buildSrc/**/Dependencies.kt',
|
'buildSrc/**/Dependencies.kt',
|
||||||
'gradle/*.versions.toml',
|
'gradle/*.versions.toml',
|
||||||
'**/versions.properties'
|
'**/versions.properties'
|
||||||
|
],
|
||||||
|
// The Gradle wrapper distribution only depends on the wrapper properties,
|
||||||
|
// which change very rarely, so it is cached separately from the Gradle
|
||||||
|
// caches. This keeps it available across the frequent *.gradle* changes
|
||||||
|
// that rotate the main cache key. See issue #269.
|
||||||
|
additionalCaches: [
|
||||||
|
{
|
||||||
|
name: 'gradle-wrapper',
|
||||||
|
path: [(0,external_path_.join)(external_os_default().homedir(), '.gradle', 'wrapper')],
|
||||||
|
pattern: ['**/gradle-wrapper.properties']
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -130947,6 +130964,19 @@ function findPackageManager(id) {
|
|||||||
}
|
}
|
||||||
return packageManager;
|
return packageManager;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* State keys used to carry an additional cache's restore-time information over
|
||||||
|
* to the post (save) action, scoped by the additional cache name.
|
||||||
|
*/
|
||||||
|
function additionalCachePrimaryKeyState(name) {
|
||||||
|
return `${STATE_CACHE_PRIMARY_KEY}-${name}`;
|
||||||
|
}
|
||||||
|
function additionalCacheMatchedKeyState(name) {
|
||||||
|
return `${CACHE_MATCHED_KEY}-${name}`;
|
||||||
|
}
|
||||||
|
function buildCacheKey(id, fileHash) {
|
||||||
|
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${id}-${fileHash}`;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* A function that generates a cache key to use.
|
* A function that generates a cache key to use.
|
||||||
* Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"".
|
* Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"".
|
||||||
@@ -130960,7 +130990,19 @@ async function computeCacheKey(packageManager, cacheDependencyPath) {
|
|||||||
if (!fileHash) {
|
if (!fileHash) {
|
||||||
throw new Error(`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`);
|
throw new Error(`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`);
|
||||||
}
|
}
|
||||||
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${packageManager.id}-${fileHash}`;
|
return buildCacheKey(packageManager.id, fileHash);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Computes the cache key for an additional cache. Unlike {@link computeCacheKey}
|
||||||
|
* this returns undefined (instead of throwing) when no file matches the pattern,
|
||||||
|
* because additional caches are optional features that many projects do not use.
|
||||||
|
*/
|
||||||
|
async function computeAdditionalCacheKey(additionalCache) {
|
||||||
|
const fileHash = await lib_glob_hashFiles(additionalCache.pattern.join('\n'));
|
||||||
|
if (!fileHash) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return buildCacheKey(additionalCache.name, fileHash);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Restore the dependency cache
|
* Restore the dependency cache
|
||||||
@@ -130984,6 +131026,29 @@ async function restore(id, cacheDependencyPath) {
|
|||||||
setOutput('cache-hit', false);
|
setOutput('cache-hit', false);
|
||||||
info(`${packageManager.id} cache is not found`);
|
info(`${packageManager.id} cache is not found`);
|
||||||
}
|
}
|
||||||
|
for (const additionalCache of packageManager.additionalCaches ?? []) {
|
||||||
|
await restoreAdditionalCache(additionalCache);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Restore an additional cache (e.g. a build-tool wrapper distribution) that is
|
||||||
|
* keyed independently of the main dependency cache so that it survives changes
|
||||||
|
* to volatile dependency files. Skips silently when the project does not use
|
||||||
|
* the corresponding feature.
|
||||||
|
*/
|
||||||
|
async function restoreAdditionalCache(additionalCache) {
|
||||||
|
const primaryKey = await computeAdditionalCacheKey(additionalCache);
|
||||||
|
if (!primaryKey) {
|
||||||
|
core_debug(`No file matched [${additionalCache.pattern}] for the ${additionalCache.name} cache, skipping.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
core_debug(`${additionalCache.name} primary key is ${primaryKey}`);
|
||||||
|
saveState(additionalCachePrimaryKeyState(additionalCache.name), primaryKey);
|
||||||
|
const matchedKey = await restoreCache(additionalCache.path, primaryKey);
|
||||||
|
if (matchedKey) {
|
||||||
|
saveState(additionalCacheMatchedKeyState(additionalCache.name), matchedKey);
|
||||||
|
info(`${additionalCache.name} cache restored from key: ${matchedKey}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Save the dependency cache
|
* Save the dependency cache
|
||||||
@@ -130994,6 +131059,9 @@ async function save(id) {
|
|||||||
const matchedKey = core.getState(CACHE_MATCHED_KEY);
|
const matchedKey = core.getState(CACHE_MATCHED_KEY);
|
||||||
// Inputs are re-evaluated before the post action, so we want the original key used for restore
|
// Inputs are re-evaluated before the post action, so we want the original key used for restore
|
||||||
const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY);
|
const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY);
|
||||||
|
for (const additionalCache of packageManager.additionalCaches ?? []) {
|
||||||
|
await saveAdditionalCache(packageManager, additionalCache);
|
||||||
|
}
|
||||||
if (!primaryKey) {
|
if (!primaryKey) {
|
||||||
core.warning('Error retrieving key from state.');
|
core.warning('Error retrieving key from state.');
|
||||||
return;
|
return;
|
||||||
@@ -131028,6 +131096,50 @@ async function save(id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Save an additional cache under its own key. Skips when no key was recorded at
|
||||||
|
* restore time (feature unused) or when the exact key was already restored.
|
||||||
|
*/
|
||||||
|
async function saveAdditionalCache(packageManager, additionalCache) {
|
||||||
|
const primaryKey = core.getState(additionalCachePrimaryKeyState(additionalCache.name));
|
||||||
|
const matchedKey = core.getState(additionalCacheMatchedKeyState(additionalCache.name));
|
||||||
|
if (!primaryKey) {
|
||||||
|
// The feature is not used by this project, nothing to save.
|
||||||
|
core.debug(`No primary key for the ${additionalCache.name} cache, not saving cache.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (matchedKey === primaryKey) {
|
||||||
|
core.info(`Cache hit occurred on the ${additionalCache.name} primary key ${primaryKey}, not saving cache.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const cacheId = await cache.saveCache(additionalCache.path, primaryKey);
|
||||||
|
if (cacheId === -1) {
|
||||||
|
core.debug(`${additionalCache.name} cache was not saved for the key: ${primaryKey}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
core.info(`${additionalCache.name} cache saved with the key: ${primaryKey}`);
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
const err = error;
|
||||||
|
if (err.name === cache.ValidationError.name) {
|
||||||
|
// The cache paths did not resolve, e.g. the wrapper distribution was
|
||||||
|
// never downloaded because a system build tool was used or the download
|
||||||
|
// failed. Optional wrapper caches must not fail the post step, so skip.
|
||||||
|
core.debug(`${additionalCache.name} cache paths do not exist, not saving cache: ${err.message}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (err.name === cache.ReserveCacheError.name) {
|
||||||
|
core.info(err.message);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (isProbablyGradleDaemonProblem(packageManager, err)) {
|
||||||
|
core.warning('Failed to save Gradle cache on Windows. If tar.exe reported "Permission denied", try to run Gradle with `--no-daemon` option. Refer to https://github.com/actions/cache/issues/454 for details.');
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @param packageManager the specified package manager by user
|
* @param packageManager the specified package manager by user
|
||||||
* @param error the error thrown by the saveCache
|
* @param error the error thrown by the saveCache
|
||||||
@@ -132093,129 +132205,6 @@ class LibericaDistributions extends JavaBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
;// CONCATENATED MODULE: ./src/distributions/liberica-nik/installer.ts
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const installer_supportedPlatform = `'linux', 'macos', 'windows'`;
|
|
||||||
const installer_supportedArchitectures = `'x64', 'aarch64'`;
|
|
||||||
class LibericaNikDistributions extends JavaBase {
|
|
||||||
constructor(installerOptions) {
|
|
||||||
super('Liberica_NIK', installerOptions);
|
|
||||||
}
|
|
||||||
async downloadTool(javaRelease) {
|
|
||||||
info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
|
||||||
let javaArchivePath = await downloadTool(javaRelease.url);
|
|
||||||
info(`Extracting Java archive...`);
|
|
||||||
const extension = getDownloadArchiveExtension();
|
|
||||||
if (process.platform === 'win32') {
|
|
||||||
javaArchivePath = renameWinArchive(javaArchivePath);
|
|
||||||
}
|
|
||||||
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
|
||||||
const archiveName = external_fs_default().readdirSync(extractedJavaPath)[0];
|
|
||||||
const archivePath = external_path_default().join(extractedJavaPath, archiveName);
|
|
||||||
const javaPath = await cacheDir(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaRelease.version), this.architecture);
|
|
||||||
return { version: javaRelease.version, path: javaPath };
|
|
||||||
}
|
|
||||||
async findPackageForDownload(range) {
|
|
||||||
const availableVersionsRaw = await this.getAvailableVersions();
|
|
||||||
const availableVersions = availableVersionsRaw
|
|
||||||
.map(item => {
|
|
||||||
const jdkVersion = this.getJdkVersion(item);
|
|
||||||
return jdkVersion ? { url: item.downloadUrl, version: jdkVersion } : null;
|
|
||||||
})
|
|
||||||
.filter((item) => item !== null);
|
|
||||||
const satisfiedVersion = availableVersions
|
|
||||||
.filter(item => isVersionSatisfies(range, item.version))
|
|
||||||
.sort((a, b) => -semver_default().compareBuild(a.version, b.version))[0];
|
|
||||||
if (!satisfiedVersion) {
|
|
||||||
const availableVersionStrings = availableVersions.map(item => item.version);
|
|
||||||
throw this.createVersionNotFoundError(range, availableVersionStrings);
|
|
||||||
}
|
|
||||||
return satisfiedVersion;
|
|
||||||
}
|
|
||||||
async getAvailableVersions() {
|
|
||||||
if (isDebug()) {
|
|
||||||
console.time('Retrieving available versions for Liberica NIK took'); // eslint-disable-line no-console
|
|
||||||
}
|
|
||||||
const url = this.prepareAvailableVersionsUrl();
|
|
||||||
core_debug(`Gathering available versions from '${url}'`);
|
|
||||||
const availableVersions = (await this.http.getJson(url)).result ?? [];
|
|
||||||
if (isDebug()) {
|
|
||||||
startGroup('Print information about available versions');
|
|
||||||
console.timeEnd('Retrieving available versions for Liberica NIK took'); // eslint-disable-line no-console
|
|
||||||
core_debug(`Available versions: [${availableVersions.length}]`);
|
|
||||||
core_debug(availableVersions.map(item => item.version).join(', '));
|
|
||||||
endGroup();
|
|
||||||
}
|
|
||||||
return availableVersions;
|
|
||||||
}
|
|
||||||
prepareAvailableVersionsUrl() {
|
|
||||||
const urlOptions = {
|
|
||||||
os: this.getPlatformOption(),
|
|
||||||
'bundle-type': this.getBundleType(),
|
|
||||||
...this.getArchitectureOptions(),
|
|
||||||
'build-type': this.stable ? 'all' : 'ea',
|
|
||||||
'installation-type': 'archive',
|
|
||||||
fields: 'downloadUrl,version,components,component,embedded'
|
|
||||||
};
|
|
||||||
const searchParams = new URLSearchParams(urlOptions).toString();
|
|
||||||
return `https://api.bell-sw.com/v1/nik/releases?${searchParams}`;
|
|
||||||
}
|
|
||||||
// NIK's top-level `version` is the GraalVM/NIK version; the JDK version that
|
|
||||||
// users select on lives in the embedded `liberica` component.
|
|
||||||
getJdkVersion(release) {
|
|
||||||
const liberica = release.components?.find(component => component.component === 'liberica');
|
|
||||||
return liberica ? this.convertVersionToSemver(liberica.version) : null;
|
|
||||||
}
|
|
||||||
// The `full` bundle adds JavaFX/Swing GUI support; otherwise use `standard`.
|
|
||||||
getBundleType() {
|
|
||||||
const [, feature] = this.packageType.split('+');
|
|
||||||
return feature?.includes('fx') ? 'full' : 'standard';
|
|
||||||
}
|
|
||||||
getArchitectureOptions() {
|
|
||||||
const arch = this.distributionArchitecture();
|
|
||||||
switch (arch) {
|
|
||||||
case 'x64':
|
|
||||||
return { bitness: '64', arch: 'x86' };
|
|
||||||
case 'aarch64':
|
|
||||||
return { bitness: '64', arch: 'arm' };
|
|
||||||
default:
|
|
||||||
throw new Error(`Architecture '${this.architecture}' is not supported. Supported architectures: ${installer_supportedArchitectures}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getPlatformOption(platform = process.platform) {
|
|
||||||
switch (platform) {
|
|
||||||
case 'darwin':
|
|
||||||
return 'macos';
|
|
||||||
case 'win32':
|
|
||||||
case 'cygwin':
|
|
||||||
return 'windows';
|
|
||||||
case 'linux':
|
|
||||||
return 'linux';
|
|
||||||
default:
|
|
||||||
throw new Error(`Platform '${platform}' is not supported. Supported platforms: ${installer_supportedPlatform}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// JDK versions come as strings like '25.0.1+16', '23+38' or '11.0.15.1+2'.
|
|
||||||
// Normalize them to valid SemVer while preserving build metadata so newer
|
|
||||||
// NIK builds of the same JDK sort ahead of older ones.
|
|
||||||
convertVersionToSemver(jdkVersion) {
|
|
||||||
const [main, build] = jdkVersion.split('+');
|
|
||||||
const parts = main.split('.');
|
|
||||||
while (parts.length < 3) {
|
|
||||||
parts.push('0');
|
|
||||||
}
|
|
||||||
const base = parts.slice(0, 3).join('.');
|
|
||||||
const buildMeta = [...parts.slice(3), ...(build ? [build] : [])];
|
|
||||||
return buildMeta.length ? `${base}+${buildMeta.join('.')}` : base;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
;// CONCATENATED MODULE: ./src/distributions/microsoft/microsoft-key.ts
|
;// CONCATENATED MODULE: ./src/distributions/microsoft/microsoft-key.ts
|
||||||
// Microsoft Build of OpenJDK GPG signing key
|
// Microsoft Build of OpenJDK GPG signing key
|
||||||
// Retrieved from: https://download.visualstudio.microsoft.com/download/pr/b90071e2-e0cf-4411-98be-dbeb09d67bf0/8622862bcd54206e158c5abca0582c9b/464279_464280_aoc_20210208.asc
|
// Retrieved from: https://download.visualstudio.microsoft.com/download/pr/b90071e2-e0cf-4411-98be-dbeb09d67bf0/8622862bcd54206e158c5abca0582c9b/464279_464280_aoc_20210208.asc
|
||||||
@@ -132356,7 +132345,7 @@ class MicrosoftDistributions extends JavaBase {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const semeru_installer_supportedArchitectures = [
|
const installer_supportedArchitectures = [
|
||||||
'x64',
|
'x64',
|
||||||
'x86',
|
'x86',
|
||||||
'ppc64le',
|
'ppc64le',
|
||||||
@@ -132370,8 +132359,8 @@ class SemeruDistribution extends JavaBase {
|
|||||||
}
|
}
|
||||||
async findPackageForDownload(version) {
|
async findPackageForDownload(version) {
|
||||||
const arch = this.distributionArchitecture();
|
const arch = this.distributionArchitecture();
|
||||||
if (!semeru_installer_supportedArchitectures.includes(arch)) {
|
if (!installer_supportedArchitectures.includes(arch)) {
|
||||||
throw new Error(`Unsupported architecture for IBM Semeru: ${this.architecture} for your current OS version, the following are supported: ${semeru_installer_supportedArchitectures.join(', ')}`);
|
throw new Error(`Unsupported architecture for IBM Semeru: ${this.architecture} for your current OS version, the following are supported: ${installer_supportedArchitectures.join(', ')}`);
|
||||||
}
|
}
|
||||||
if (!this.stable) {
|
if (!this.stable) {
|
||||||
throw new Error('IBM Semeru does not provide builds for early access versions');
|
throw new Error('IBM Semeru does not provide builds for early access versions');
|
||||||
@@ -133661,7 +133650,6 @@ class KonaDistribution extends JavaBase {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var JavaDistribution;
|
var JavaDistribution;
|
||||||
(function (JavaDistribution) {
|
(function (JavaDistribution) {
|
||||||
JavaDistribution["Adopt"] = "adopt";
|
JavaDistribution["Adopt"] = "adopt";
|
||||||
@@ -133670,7 +133658,6 @@ var JavaDistribution;
|
|||||||
JavaDistribution["Temurin"] = "temurin";
|
JavaDistribution["Temurin"] = "temurin";
|
||||||
JavaDistribution["Zulu"] = "zulu";
|
JavaDistribution["Zulu"] = "zulu";
|
||||||
JavaDistribution["Liberica"] = "liberica";
|
JavaDistribution["Liberica"] = "liberica";
|
||||||
JavaDistribution["LibericaNik"] = "liberica-nik";
|
|
||||||
JavaDistribution["JdkFile"] = "jdkfile";
|
JavaDistribution["JdkFile"] = "jdkfile";
|
||||||
JavaDistribution["Microsoft"] = "microsoft";
|
JavaDistribution["Microsoft"] = "microsoft";
|
||||||
JavaDistribution["Semeru"] = "semeru";
|
JavaDistribution["Semeru"] = "semeru";
|
||||||
@@ -133698,8 +133685,6 @@ function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
|||||||
return new ZuluDistribution(installerOptions);
|
return new ZuluDistribution(installerOptions);
|
||||||
case JavaDistribution.Liberica:
|
case JavaDistribution.Liberica:
|
||||||
return new LibericaDistributions(installerOptions);
|
return new LibericaDistributions(installerOptions);
|
||||||
case JavaDistribution.LibericaNik:
|
|
||||||
return new LibericaNikDistributions(installerOptions);
|
|
||||||
case JavaDistribution.Microsoft:
|
case JavaDistribution.Microsoft:
|
||||||
return new MicrosoftDistributions(installerOptions);
|
return new MicrosoftDistributions(installerOptions);
|
||||||
case JavaDistribution.Semeru:
|
case JavaDistribution.Semeru:
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
- [Adopt](#Adopt)
|
- [Adopt](#Adopt)
|
||||||
- [Zulu](#Zulu)
|
- [Zulu](#Zulu)
|
||||||
- [Liberica](#Liberica)
|
- [Liberica](#Liberica)
|
||||||
- [Liberica Native Image Kit](#Liberica-Native-Image-Kit)
|
|
||||||
- [Microsoft](#Microsoft)
|
- [Microsoft](#Microsoft)
|
||||||
- [Amazon Corretto](#Amazon-Corretto)
|
- [Amazon Corretto](#Amazon-Corretto)
|
||||||
- [Oracle](#Oracle)
|
- [Oracle](#Oracle)
|
||||||
@@ -86,20 +85,6 @@ steps:
|
|||||||
- run: java --version
|
- run: java --version
|
||||||
```
|
```
|
||||||
|
|
||||||
### Liberica Native Image Kit
|
|
||||||
Liberica Native Image Kit (NIK) is a GraalVM-based distribution. `java-version` selects the underlying JDK version (e.g. `17`, `21`, `25`). Use `java-package: jdk+fx` to get the `full` bundle with JavaFX/Swing support; otherwise the `standard` bundle (with extra languages) is installed. Available on Linux, macOS and Windows for `x64` and `aarch64`.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- uses: actions/setup-java@v5
|
|
||||||
with:
|
|
||||||
distribution: 'liberica-nik'
|
|
||||||
java-version: '25'
|
|
||||||
java-package: jdk # optional (jdk or jdk+fx) - defaults to jdk
|
|
||||||
- run: native-image --version
|
|
||||||
```
|
|
||||||
|
|
||||||
### Microsoft
|
### Microsoft
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@@ -304,8 +289,7 @@ To run the JavaFX application in CI:
|
|||||||
## Ensuring the Maven cache is complete (plugin dependencies)
|
## Ensuring the Maven cache is complete (plugin dependencies)
|
||||||
|
|
||||||
When you enable `cache: maven`, the action caches your local Maven repository
|
When you enable `cache: maven`, the action caches your local Maven repository
|
||||||
(`~/.m2/repository`) and downloaded Maven Wrapper distributions
|
(`~/.m2/repository`). The cache key is a hash of your Maven inputs — every
|
||||||
(`~/.m2/wrapper/dists`). The cache key is a hash of your Maven inputs — every
|
|
||||||
`**/pom.xml`, plus `**/.mvn/wrapper/maven-wrapper.properties` and
|
`**/pom.xml`, plus `**/.mvn/wrapper/maven-wrapper.properties` and
|
||||||
`**/.mvn/extensions.xml` — so changing any of those files (for example bumping
|
`**/.mvn/extensions.xml` — so changing any of those files (for example bumping
|
||||||
the wrapper version or editing core extensions) produces a new key and
|
the wrapper version or editing core extensions) produces a new key and
|
||||||
@@ -313,6 +297,14 @@ invalidates the cache. At the end of the job the action saves whatever was
|
|||||||
downloaded during that run. It does **not** re-save the cache when the key
|
downloaded during that run. It does **not** re-save the cache when the key
|
||||||
already matches (a cache *hit*).
|
already matches (a cache *hit*).
|
||||||
|
|
||||||
|
Downloaded Maven Wrapper distributions (`~/.m2/wrapper/dists`) are cached in a
|
||||||
|
**separate** cache entry keyed only on `**/.mvn/wrapper/maven-wrapper.properties`.
|
||||||
|
Because the wrapper distribution changes far less often than your `pom.xml`
|
||||||
|
files, this keeps it available across the frequent dependency changes that
|
||||||
|
rotate the main cache key, so wrapper-based (`./mvnw`) builds don't re-download
|
||||||
|
the Maven distribution on every dependency change. See
|
||||||
|
[issue #1095](https://github.com/actions/setup-java/issues/1095).
|
||||||
|
|
||||||
Maven resolves **plugin** dependencies lazily: it only downloads the plugins and
|
Maven resolves **plugin** dependencies lazily: it only downloads the plugins and
|
||||||
plugin dependencies required by the goals that actually execute. As a result, the
|
plugin dependencies required by the goals that actually execute. As a result, the
|
||||||
run that first creates the cache determines what is stored. If that run executed a
|
run that first creates the cache determines what is stored. If that run executed a
|
||||||
@@ -816,8 +808,6 @@ The `setup-java` action generates a basic [Maven Toolchains declaration](https:/
|
|||||||
### Installing Multiple JDKs With Toolchains
|
### Installing Multiple JDKs With Toolchains
|
||||||
Subsequent calls to `setup-java` with distinct distribution and version parameters will continue to extend the toolchains declaration and make all specified Java versions available.
|
Subsequent calls to `setup-java` with distinct distribution and version parameters will continue to extend the toolchains declaration and make all specified Java versions available.
|
||||||
|
|
||||||
Toolchain entries are always merged non-destructively: existing JDK, custom, and user-managed toolchains are preserved, and only an entry with the exact same `type` and `provides.id` is replaced. This behavior is independent of the `overwrite-settings` input, which only controls regeneration of `settings.xml`. As a result, running `setup-java` several times in the same job (for example in multiple steps or with multiple `java-version` values) accumulates every JDK in `toolchains.xml` instead of dropping previously registered entries.
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/setup-java@v5
|
- uses: actions/setup-java@v5
|
||||||
|
|||||||
194
src/cache.ts
194
src/cache.ts
@@ -12,6 +12,30 @@ const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key';
|
|||||||
const CACHE_MATCHED_KEY = 'cache-matched-key';
|
const CACHE_MATCHED_KEY = 'cache-matched-key';
|
||||||
const CACHE_KEY_PREFIX = 'setup-java';
|
const CACHE_KEY_PREFIX = 'setup-java';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An additional cache entry that is restored and saved independently of the
|
||||||
|
* main dependency cache. Used for build-tool wrapper distributions that rarely
|
||||||
|
* change (e.g. the Maven wrapper distribution) so that they are not evicted
|
||||||
|
* every time a volatile dependency file such as pom.xml changes. See
|
||||||
|
* https://github.com/actions/setup-java/issues/1095.
|
||||||
|
*/
|
||||||
|
interface AdditionalCache {
|
||||||
|
/**
|
||||||
|
* Short identifier for the cache, used to build its cache key and to scope
|
||||||
|
* the state keys that carry information from restore to save.
|
||||||
|
*/
|
||||||
|
name: string;
|
||||||
|
/**
|
||||||
|
* Paths that make up this cache entry.
|
||||||
|
*/
|
||||||
|
path: string[];
|
||||||
|
/**
|
||||||
|
* Glob patterns whose hash forms the cache key. If no file matches, the
|
||||||
|
* cache is skipped silently (the project simply does not use this feature).
|
||||||
|
*/
|
||||||
|
pattern: string[];
|
||||||
|
}
|
||||||
|
|
||||||
interface PackageManager {
|
interface PackageManager {
|
||||||
id: 'maven' | 'gradle' | 'sbt';
|
id: 'maven' | 'gradle' | 'sbt';
|
||||||
/**
|
/**
|
||||||
@@ -19,27 +43,36 @@ interface PackageManager {
|
|||||||
*/
|
*/
|
||||||
path: string[];
|
path: string[];
|
||||||
pattern: string[];
|
pattern: string[];
|
||||||
|
/**
|
||||||
|
* Additional caches keyed independently of the main dependency cache.
|
||||||
|
*/
|
||||||
|
additionalCaches?: AdditionalCache[];
|
||||||
}
|
}
|
||||||
const supportedPackageManager: PackageManager[] = [
|
const supportedPackageManager: PackageManager[] = [
|
||||||
{
|
{
|
||||||
id: 'maven',
|
id: 'maven',
|
||||||
path: [
|
path: [join(os.homedir(), '.m2', 'repository')],
|
||||||
join(os.homedir(), '.m2', 'repository'),
|
|
||||||
join(os.homedir(), '.m2', 'wrapper', 'dists')
|
|
||||||
],
|
|
||||||
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven
|
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven
|
||||||
pattern: [
|
pattern: [
|
||||||
'**/pom.xml',
|
'**/pom.xml',
|
||||||
'**/.mvn/wrapper/maven-wrapper.properties',
|
'**/.mvn/wrapper/maven-wrapper.properties',
|
||||||
'**/.mvn/extensions.xml'
|
'**/.mvn/extensions.xml'
|
||||||
|
],
|
||||||
|
// The Maven wrapper distribution only depends on the wrapper properties,
|
||||||
|
// which change very rarely, so it is cached separately from the local
|
||||||
|
// repository. This keeps it available across the frequent pom.xml changes
|
||||||
|
// that rotate the main cache key. See issue #1095.
|
||||||
|
additionalCaches: [
|
||||||
|
{
|
||||||
|
name: 'maven-wrapper',
|
||||||
|
path: [join(os.homedir(), '.m2', 'wrapper', 'dists')],
|
||||||
|
pattern: ['**/.mvn/wrapper/maven-wrapper.properties']
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'gradle',
|
id: 'gradle',
|
||||||
path: [
|
path: [join(os.homedir(), '.gradle', 'caches')],
|
||||||
join(os.homedir(), '.gradle', 'caches'),
|
|
||||||
join(os.homedir(), '.gradle', 'wrapper')
|
|
||||||
],
|
|
||||||
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---gradle
|
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---gradle
|
||||||
pattern: [
|
pattern: [
|
||||||
'**/*.gradle*',
|
'**/*.gradle*',
|
||||||
@@ -48,6 +81,17 @@ const supportedPackageManager: PackageManager[] = [
|
|||||||
'buildSrc/**/Dependencies.kt',
|
'buildSrc/**/Dependencies.kt',
|
||||||
'gradle/*.versions.toml',
|
'gradle/*.versions.toml',
|
||||||
'**/versions.properties'
|
'**/versions.properties'
|
||||||
|
],
|
||||||
|
// The Gradle wrapper distribution only depends on the wrapper properties,
|
||||||
|
// which change very rarely, so it is cached separately from the Gradle
|
||||||
|
// caches. This keeps it available across the frequent *.gradle* changes
|
||||||
|
// that rotate the main cache key. See issue #269.
|
||||||
|
additionalCaches: [
|
||||||
|
{
|
||||||
|
name: 'gradle-wrapper',
|
||||||
|
path: [join(os.homedir(), '.gradle', 'wrapper')],
|
||||||
|
pattern: ['**/gradle-wrapper.properties']
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -87,6 +131,21 @@ function findPackageManager(id: string): PackageManager {
|
|||||||
return packageManager;
|
return packageManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* State keys used to carry an additional cache's restore-time information over
|
||||||
|
* to the post (save) action, scoped by the additional cache name.
|
||||||
|
*/
|
||||||
|
function additionalCachePrimaryKeyState(name: string): string {
|
||||||
|
return `${STATE_CACHE_PRIMARY_KEY}-${name}`;
|
||||||
|
}
|
||||||
|
function additionalCacheMatchedKeyState(name: string): string {
|
||||||
|
return `${CACHE_MATCHED_KEY}-${name}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildCacheKey(id: string, fileHash: string): string {
|
||||||
|
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${id}-${fileHash}`;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A function that generates a cache key to use.
|
* A function that generates a cache key to use.
|
||||||
* Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"".
|
* Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"".
|
||||||
@@ -105,7 +164,22 @@ async function computeCacheKey(
|
|||||||
`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`
|
`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${packageManager.id}-${fileHash}`;
|
return buildCacheKey(packageManager.id, fileHash);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes the cache key for an additional cache. Unlike {@link computeCacheKey}
|
||||||
|
* this returns undefined (instead of throwing) when no file matches the pattern,
|
||||||
|
* because additional caches are optional features that many projects do not use.
|
||||||
|
*/
|
||||||
|
async function computeAdditionalCacheKey(
|
||||||
|
additionalCache: AdditionalCache
|
||||||
|
): Promise<string | undefined> {
|
||||||
|
const fileHash = await glob.hashFiles(additionalCache.pattern.join('\n'));
|
||||||
|
if (!fileHash) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return buildCacheKey(additionalCache.name, fileHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,6 +204,40 @@ export async function restore(id: string, cacheDependencyPath: string) {
|
|||||||
core.setOutput('cache-hit', false);
|
core.setOutput('cache-hit', false);
|
||||||
core.info(`${packageManager.id} cache is not found`);
|
core.info(`${packageManager.id} cache is not found`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const additionalCache of packageManager.additionalCaches ?? []) {
|
||||||
|
await restoreAdditionalCache(additionalCache);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restore an additional cache (e.g. a build-tool wrapper distribution) that is
|
||||||
|
* keyed independently of the main dependency cache so that it survives changes
|
||||||
|
* to volatile dependency files. Skips silently when the project does not use
|
||||||
|
* the corresponding feature.
|
||||||
|
*/
|
||||||
|
async function restoreAdditionalCache(additionalCache: AdditionalCache) {
|
||||||
|
const primaryKey = await computeAdditionalCacheKey(additionalCache);
|
||||||
|
if (!primaryKey) {
|
||||||
|
core.debug(
|
||||||
|
`No file matched [${additionalCache.pattern}] for the ${additionalCache.name} cache, skipping.`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
core.debug(`${additionalCache.name} primary key is ${primaryKey}`);
|
||||||
|
core.saveState(
|
||||||
|
additionalCachePrimaryKeyState(additionalCache.name),
|
||||||
|
primaryKey
|
||||||
|
);
|
||||||
|
|
||||||
|
const matchedKey = await cache.restoreCache(additionalCache.path, primaryKey);
|
||||||
|
if (matchedKey) {
|
||||||
|
core.saveState(
|
||||||
|
additionalCacheMatchedKeyState(additionalCache.name),
|
||||||
|
matchedKey
|
||||||
|
);
|
||||||
|
core.info(`${additionalCache.name} cache restored from key: ${matchedKey}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -143,6 +251,10 @@ export async function save(id: string) {
|
|||||||
// Inputs are re-evaluated before the post action, so we want the original key used for restore
|
// Inputs are re-evaluated before the post action, so we want the original key used for restore
|
||||||
const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY);
|
const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY);
|
||||||
|
|
||||||
|
for (const additionalCache of packageManager.additionalCaches ?? []) {
|
||||||
|
await saveAdditionalCache(packageManager, additionalCache);
|
||||||
|
}
|
||||||
|
|
||||||
if (!primaryKey) {
|
if (!primaryKey) {
|
||||||
core.warning('Error retrieving key from state.');
|
core.warning('Error retrieving key from state.');
|
||||||
return;
|
return;
|
||||||
@@ -180,6 +292,70 @@ export async function save(id: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save an additional cache under its own key. Skips when no key was recorded at
|
||||||
|
* restore time (feature unused) or when the exact key was already restored.
|
||||||
|
*/
|
||||||
|
async function saveAdditionalCache(
|
||||||
|
packageManager: PackageManager,
|
||||||
|
additionalCache: AdditionalCache
|
||||||
|
) {
|
||||||
|
const primaryKey = core.getState(
|
||||||
|
additionalCachePrimaryKeyState(additionalCache.name)
|
||||||
|
);
|
||||||
|
const matchedKey = core.getState(
|
||||||
|
additionalCacheMatchedKeyState(additionalCache.name)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!primaryKey) {
|
||||||
|
// The feature is not used by this project, nothing to save.
|
||||||
|
core.debug(
|
||||||
|
`No primary key for the ${additionalCache.name} cache, not saving cache.`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
} else if (matchedKey === primaryKey) {
|
||||||
|
core.info(
|
||||||
|
`Cache hit occurred on the ${additionalCache.name} primary key ${primaryKey}, not saving cache.`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const cacheId = await cache.saveCache(additionalCache.path, primaryKey);
|
||||||
|
if (cacheId === -1) {
|
||||||
|
core.debug(
|
||||||
|
`${additionalCache.name} cache was not saved for the key: ${primaryKey}`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
core.info(
|
||||||
|
`${additionalCache.name} cache saved with the key: ${primaryKey}`
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
const err = error as Error;
|
||||||
|
|
||||||
|
if (err.name === cache.ValidationError.name) {
|
||||||
|
// The cache paths did not resolve, e.g. the wrapper distribution was
|
||||||
|
// never downloaded because a system build tool was used or the download
|
||||||
|
// failed. Optional wrapper caches must not fail the post step, so skip.
|
||||||
|
core.debug(
|
||||||
|
`${additionalCache.name} cache paths do not exist, not saving cache: ${err.message}`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err.name === cache.ReserveCacheError.name) {
|
||||||
|
core.info(err.message);
|
||||||
|
} else {
|
||||||
|
if (isProbablyGradleDaemonProblem(packageManager, err)) {
|
||||||
|
core.warning(
|
||||||
|
'Failed to save Gradle cache on Windows. If tar.exe reported "Permission denied", try to run Gradle with `--no-daemon` option. Refer to https://github.com/actions/cache/issues/454 for details.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param packageManager the specified package manager by user
|
* @param packageManager the specified package manager by user
|
||||||
* @param error the error thrown by the saveCache
|
* @param error the error thrown by the saveCache
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import {
|
|||||||
TemurinImplementation
|
TemurinImplementation
|
||||||
} from './temurin/installer.js';
|
} from './temurin/installer.js';
|
||||||
import {LibericaDistributions} from './liberica/installer.js';
|
import {LibericaDistributions} from './liberica/installer.js';
|
||||||
import {LibericaNikDistributions} from './liberica-nik/installer.js';
|
|
||||||
import {MicrosoftDistributions} from './microsoft/installer.js';
|
import {MicrosoftDistributions} from './microsoft/installer.js';
|
||||||
import {SemeruDistribution} from './semeru/installer.js';
|
import {SemeruDistribution} from './semeru/installer.js';
|
||||||
import {CorrettoDistribution} from './corretto/installer.js';
|
import {CorrettoDistribution} from './corretto/installer.js';
|
||||||
@@ -29,7 +28,6 @@ enum JavaDistribution {
|
|||||||
Temurin = 'temurin',
|
Temurin = 'temurin',
|
||||||
Zulu = 'zulu',
|
Zulu = 'zulu',
|
||||||
Liberica = 'liberica',
|
Liberica = 'liberica',
|
||||||
LibericaNik = 'liberica-nik',
|
|
||||||
JdkFile = 'jdkfile',
|
JdkFile = 'jdkfile',
|
||||||
Microsoft = 'microsoft',
|
Microsoft = 'microsoft',
|
||||||
Semeru = 'semeru',
|
Semeru = 'semeru',
|
||||||
@@ -71,8 +69,6 @@ export function getJavaDistribution(
|
|||||||
return new ZuluDistribution(installerOptions);
|
return new ZuluDistribution(installerOptions);
|
||||||
case JavaDistribution.Liberica:
|
case JavaDistribution.Liberica:
|
||||||
return new LibericaDistributions(installerOptions);
|
return new LibericaDistributions(installerOptions);
|
||||||
case JavaDistribution.LibericaNik:
|
|
||||||
return new LibericaNikDistributions(installerOptions);
|
|
||||||
case JavaDistribution.Microsoft:
|
case JavaDistribution.Microsoft:
|
||||||
return new MicrosoftDistributions(installerOptions);
|
return new MicrosoftDistributions(installerOptions);
|
||||||
case JavaDistribution.Semeru:
|
case JavaDistribution.Semeru:
|
||||||
|
|||||||
@@ -1,180 +0,0 @@
|
|||||||
import {JavaBase} from '../base-installer.js';
|
|
||||||
import {
|
|
||||||
JavaDownloadRelease,
|
|
||||||
JavaInstallerOptions,
|
|
||||||
JavaInstallerResults
|
|
||||||
} from '../base-models.js';
|
|
||||||
import semver from 'semver';
|
|
||||||
import {
|
|
||||||
extractJdkFile,
|
|
||||||
getDownloadArchiveExtension,
|
|
||||||
isVersionSatisfies,
|
|
||||||
renameWinArchive
|
|
||||||
} from '../../util.js';
|
|
||||||
import * as core from '@actions/core';
|
|
||||||
import {ArchitectureOptions, NikVersion, OsVersions} from './models.js';
|
|
||||||
import * as tc from '@actions/tool-cache';
|
|
||||||
import fs from 'fs';
|
|
||||||
import path from 'path';
|
|
||||||
|
|
||||||
const supportedPlatform = `'linux', 'macos', 'windows'`;
|
|
||||||
|
|
||||||
const supportedArchitectures = `'x64', 'aarch64'`;
|
|
||||||
|
|
||||||
export class LibericaNikDistributions extends JavaBase {
|
|
||||||
constructor(installerOptions: JavaInstallerOptions) {
|
|
||||||
super('Liberica_NIK', installerOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected async downloadTool(
|
|
||||||
javaRelease: JavaDownloadRelease
|
|
||||||
): Promise<JavaInstallerResults> {
|
|
||||||
core.info(
|
|
||||||
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
|
||||||
);
|
|
||||||
let javaArchivePath = await tc.downloadTool(javaRelease.url);
|
|
||||||
|
|
||||||
core.info(`Extracting Java archive...`);
|
|
||||||
const extension = getDownloadArchiveExtension();
|
|
||||||
if (process.platform === 'win32') {
|
|
||||||
javaArchivePath = renameWinArchive(javaArchivePath);
|
|
||||||
}
|
|
||||||
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
|
||||||
|
|
||||||
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
|
||||||
const archivePath = path.join(extractedJavaPath, archiveName);
|
|
||||||
|
|
||||||
const javaPath = await tc.cacheDir(
|
|
||||||
archivePath,
|
|
||||||
this.toolcacheFolderName,
|
|
||||||
this.getToolcacheVersionName(javaRelease.version),
|
|
||||||
this.architecture
|
|
||||||
);
|
|
||||||
|
|
||||||
return {version: javaRelease.version, path: javaPath};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected async findPackageForDownload(
|
|
||||||
range: string
|
|
||||||
): Promise<JavaDownloadRelease> {
|
|
||||||
const availableVersionsRaw = await this.getAvailableVersions();
|
|
||||||
|
|
||||||
const availableVersions = availableVersionsRaw
|
|
||||||
.map(item => {
|
|
||||||
const jdkVersion = this.getJdkVersion(item);
|
|
||||||
return jdkVersion ? {url: item.downloadUrl, version: jdkVersion} : null;
|
|
||||||
})
|
|
||||||
.filter((item): item is {url: string; version: string} => item !== null);
|
|
||||||
|
|
||||||
const satisfiedVersion = availableVersions
|
|
||||||
.filter(item => isVersionSatisfies(range, item.version))
|
|
||||||
.sort((a, b) => -semver.compareBuild(a.version, b.version))[0];
|
|
||||||
|
|
||||||
if (!satisfiedVersion) {
|
|
||||||
const availableVersionStrings = availableVersions.map(
|
|
||||||
item => item.version
|
|
||||||
);
|
|
||||||
throw this.createVersionNotFoundError(range, availableVersionStrings);
|
|
||||||
}
|
|
||||||
|
|
||||||
return satisfiedVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async getAvailableVersions(): Promise<NikVersion[]> {
|
|
||||||
if (core.isDebug()) {
|
|
||||||
console.time('Retrieving available versions for Liberica NIK took'); // eslint-disable-line no-console
|
|
||||||
}
|
|
||||||
const url = this.prepareAvailableVersionsUrl();
|
|
||||||
|
|
||||||
core.debug(`Gathering available versions from '${url}'`);
|
|
||||||
|
|
||||||
const availableVersions =
|
|
||||||
(await this.http.getJson<NikVersion[]>(url)).result ?? [];
|
|
||||||
|
|
||||||
if (core.isDebug()) {
|
|
||||||
core.startGroup('Print information about available versions');
|
|
||||||
console.timeEnd('Retrieving available versions for Liberica NIK took'); // eslint-disable-line no-console
|
|
||||||
core.debug(`Available versions: [${availableVersions.length}]`);
|
|
||||||
core.debug(availableVersions.map(item => item.version).join(', '));
|
|
||||||
core.endGroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
return availableVersions;
|
|
||||||
}
|
|
||||||
|
|
||||||
private prepareAvailableVersionsUrl() {
|
|
||||||
const urlOptions = {
|
|
||||||
os: this.getPlatformOption(),
|
|
||||||
'bundle-type': this.getBundleType(),
|
|
||||||
...this.getArchitectureOptions(),
|
|
||||||
'build-type': this.stable ? 'all' : 'ea',
|
|
||||||
'installation-type': 'archive',
|
|
||||||
fields: 'downloadUrl,version,components,component,embedded'
|
|
||||||
};
|
|
||||||
|
|
||||||
const searchParams = new URLSearchParams(urlOptions).toString();
|
|
||||||
|
|
||||||
return `https://api.bell-sw.com/v1/nik/releases?${searchParams}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// NIK's top-level `version` is the GraalVM/NIK version; the JDK version that
|
|
||||||
// users select on lives in the embedded `liberica` component.
|
|
||||||
private getJdkVersion(release: NikVersion): string | null {
|
|
||||||
const liberica = release.components?.find(
|
|
||||||
component => component.component === 'liberica'
|
|
||||||
);
|
|
||||||
return liberica ? this.convertVersionToSemver(liberica.version) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The `full` bundle adds JavaFX/Swing GUI support; otherwise use `standard`.
|
|
||||||
private getBundleType(): string {
|
|
||||||
const [, feature] = this.packageType.split('+');
|
|
||||||
return feature?.includes('fx') ? 'full' : 'standard';
|
|
||||||
}
|
|
||||||
|
|
||||||
private getArchitectureOptions(): ArchitectureOptions {
|
|
||||||
const arch = this.distributionArchitecture();
|
|
||||||
switch (arch) {
|
|
||||||
case 'x64':
|
|
||||||
return {bitness: '64', arch: 'x86'};
|
|
||||||
case 'aarch64':
|
|
||||||
return {bitness: '64', arch: 'arm'};
|
|
||||||
default:
|
|
||||||
throw new Error(
|
|
||||||
`Architecture '${this.architecture}' is not supported. Supported architectures: ${supportedArchitectures}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private getPlatformOption(
|
|
||||||
platform: NodeJS.Platform = process.platform
|
|
||||||
): OsVersions {
|
|
||||||
switch (platform) {
|
|
||||||
case 'darwin':
|
|
||||||
return 'macos';
|
|
||||||
case 'win32':
|
|
||||||
case 'cygwin':
|
|
||||||
return 'windows';
|
|
||||||
case 'linux':
|
|
||||||
return 'linux';
|
|
||||||
default:
|
|
||||||
throw new Error(
|
|
||||||
`Platform '${platform}' is not supported. Supported platforms: ${supportedPlatform}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// JDK versions come as strings like '25.0.1+16', '23+38' or '11.0.15.1+2'.
|
|
||||||
// Normalize them to valid SemVer while preserving build metadata so newer
|
|
||||||
// NIK builds of the same JDK sort ahead of older ones.
|
|
||||||
private convertVersionToSemver(jdkVersion: string): string {
|
|
||||||
const [main, build] = jdkVersion.split('+');
|
|
||||||
const parts = main.split('.');
|
|
||||||
while (parts.length < 3) {
|
|
||||||
parts.push('0');
|
|
||||||
}
|
|
||||||
const base = parts.slice(0, 3).join('.');
|
|
||||||
const buildMeta = [...parts.slice(3), ...(build ? [build] : [])];
|
|
||||||
return buildMeta.length ? `${base}+${buildMeta.join('.')}` : base;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
// Models from https://api.bell-sw.com/api.html (NIK product)
|
|
||||||
|
|
||||||
export type Bitness = '32' | '64';
|
|
||||||
export type ArchType = 'arm' | 'ppc' | 'sparc' | 'x86';
|
|
||||||
|
|
||||||
export type OsVersions = 'linux' | 'linux-musl' | 'macos' | 'windows';
|
|
||||||
|
|
||||||
export interface ArchitectureOptions {
|
|
||||||
bitness: Bitness;
|
|
||||||
arch: ArchType;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NikComponent {
|
|
||||||
component: string;
|
|
||||||
version: string;
|
|
||||||
embedded?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NikVersion {
|
|
||||||
// The main Liberica NIK VM bundle download URL.
|
|
||||||
downloadUrl: string;
|
|
||||||
// NIK/GraalVM version (e.g. '24.1.0+1'), kept for logging only.
|
|
||||||
version: string;
|
|
||||||
// The embedded `liberica` component carries the actual JDK version.
|
|
||||||
components: NikComponent[];
|
|
||||||
}
|
|
||||||
@@ -5,6 +5,7 @@ import * as core from '@actions/core';
|
|||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
import * as constants from './constants.js';
|
import * as constants from './constants.js';
|
||||||
|
|
||||||
|
import {getBooleanInput} from './util.js';
|
||||||
import {create as xmlCreate} from 'xmlbuilder2';
|
import {create as xmlCreate} from 'xmlbuilder2';
|
||||||
|
|
||||||
interface JdkInfo {
|
interface JdkInfo {
|
||||||
@@ -26,6 +27,10 @@ export async function configureToolchains(
|
|||||||
const settingsDirectory =
|
const settingsDirectory =
|
||||||
core.getInput(constants.INPUT_SETTINGS_PATH) ||
|
core.getInput(constants.INPUT_SETTINGS_PATH) ||
|
||||||
path.join(os.homedir(), constants.M2_DIR);
|
path.join(os.homedir(), constants.M2_DIR);
|
||||||
|
const overwriteSettings = getBooleanInput(
|
||||||
|
constants.INPUT_OVERWRITE_SETTINGS,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
await createToolchainsSettings({
|
await createToolchainsSettings({
|
||||||
jdkInfo: {
|
jdkInfo: {
|
||||||
@@ -34,16 +39,19 @@ export async function configureToolchains(
|
|||||||
id,
|
id,
|
||||||
jdkHome
|
jdkHome
|
||||||
},
|
},
|
||||||
settingsDirectory
|
settingsDirectory,
|
||||||
|
overwriteSettings
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createToolchainsSettings({
|
export async function createToolchainsSettings({
|
||||||
jdkInfo,
|
jdkInfo,
|
||||||
settingsDirectory
|
settingsDirectory,
|
||||||
|
overwriteSettings
|
||||||
}: {
|
}: {
|
||||||
jdkInfo: JdkInfo;
|
jdkInfo: JdkInfo;
|
||||||
settingsDirectory: string;
|
settingsDirectory: string;
|
||||||
|
overwriteSettings: boolean;
|
||||||
}) {
|
}) {
|
||||||
core.info(
|
core.info(
|
||||||
`Creating ${constants.MVN_TOOLCHAINS_FILE} for JDK version ${jdkInfo.version} from ${jdkInfo.vendor}`
|
`Creating ${constants.MVN_TOOLCHAINS_FILE} for JDK version ${jdkInfo.version} from ${jdkInfo.vendor}`
|
||||||
@@ -60,7 +68,11 @@ export async function createToolchainsSettings({
|
|||||||
jdkInfo.id,
|
jdkInfo.id,
|
||||||
jdkInfo.jdkHome
|
jdkInfo.jdkHome
|
||||||
);
|
);
|
||||||
await writeToolchainsFileToDisk(settingsDirectory, updatedToolchains);
|
await writeToolchainsFileToDisk(
|
||||||
|
settingsDirectory,
|
||||||
|
updatedToolchains,
|
||||||
|
overwriteSettings
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// only exported for testing purposes
|
// only exported for testing purposes
|
||||||
@@ -160,19 +172,22 @@ async function readExistingToolchainsFile(directory: string) {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
async function writeToolchainsFileToDisk(directory: string, settings: string) {
|
async function writeToolchainsFileToDisk(
|
||||||
|
directory: string,
|
||||||
|
settings: string,
|
||||||
|
overwriteSettings: boolean
|
||||||
|
) {
|
||||||
const location = path.join(directory, constants.MVN_TOOLCHAINS_FILE);
|
const location = path.join(directory, constants.MVN_TOOLCHAINS_FILE);
|
||||||
const settingsExists = fs.existsSync(location);
|
const settingsExists = fs.existsSync(location);
|
||||||
// The toolchains file is produced by a non-destructive merge (existing JDK,
|
if (settingsExists && overwriteSettings) {
|
||||||
// custom, and non-jdk toolchains are preserved – see generateToolchainDefinition),
|
core.info(`Overwriting existing file ${location}`);
|
||||||
// so it is always safe to write it. Unlike settings.xml, it is therefore not
|
} else if (!settingsExists) {
|
||||||
// gated behind the `overwrite-settings` input; that would prevent subsequent
|
|
||||||
// setup-java runs from registering additional JDKs and silently drop the
|
|
||||||
// toolchain entries created by earlier runs.
|
|
||||||
if (settingsExists) {
|
|
||||||
core.info(`Updating existing file ${location}`);
|
|
||||||
} else {
|
|
||||||
core.info(`Writing to ${location}`);
|
core.info(`Writing to ${location}`);
|
||||||
|
} else {
|
||||||
|
core.info(
|
||||||
|
`Skipping generation of ${location} because file already exists and overwriting is not enabled`
|
||||||
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fs.writeFileSync(location, settings, {
|
return fs.writeFileSync(location, settings, {
|
||||||
|
|||||||
Reference in New Issue
Block a user