mirror of
https://github.com/actions/setup-java.git
synced 2026-07-08 16:20:44 +03:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9051c81518 | |||
| e8aa5c4d23 | |||
| f29bb0b8db | |||
| a2081b9e85 | |||
| 39f01ea699 |
@@ -669,77 +669,3 @@ jobs:
|
|||||||
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
|
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
|
||||||
run: bash __tests__/verify-java.sh "17.0.10" "$JAVA_PATH"
|
run: bash __tests__/verify-java.sh "17.0.10" "$JAVA_PATH"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
setup-java-set-default:
|
|
||||||
name: set-default option - ${{ matrix.os }}
|
|
||||||
needs: setup-java-major-versions
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v6
|
|
||||||
- name: Setup Java 17 as default
|
|
||||||
uses: ./
|
|
||||||
id: setup-java-17
|
|
||||||
with:
|
|
||||||
distribution: 'temurin'
|
|
||||||
java-version: '17'
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- name: Setup Java 21 without setting as default
|
|
||||||
uses: ./
|
|
||||||
id: setup-java-21
|
|
||||||
with:
|
|
||||||
distribution: 'temurin'
|
|
||||||
java-version: '21'
|
|
||||||
set-default: false
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- name: Verify JAVA_HOME still points to Java 17
|
|
||||||
run: |
|
|
||||||
echo "JAVA_HOME=$JAVA_HOME"
|
|
||||||
echo "Java 17 path=${{ steps.setup-java-17.outputs.path }}"
|
|
||||||
if [ "$JAVA_HOME" != "${{ steps.setup-java-17.outputs.path }}" ]; then
|
|
||||||
echo "JAVA_HOME should still point to Java 17"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
shell: bash
|
|
||||||
- name: Verify java -version reports Java 17
|
|
||||||
run: |
|
|
||||||
JAVA_VERSION=$(java -version 2>&1 | head -1)
|
|
||||||
echo "java -version: $JAVA_VERSION"
|
|
||||||
if ! echo "$JAVA_VERSION" | grep -q "17"; then
|
|
||||||
echo "Default java should still be version 17"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
shell: bash
|
|
||||||
- name: Verify JAVA_HOME_21 env var is set
|
|
||||||
run: |
|
|
||||||
$envName = "JAVA_HOME_21_${env:RUNNER_ARCH}"
|
|
||||||
$JavaVersionPath = [Environment]::GetEnvironmentVariable($envName)
|
|
||||||
if (-not $JavaVersionPath) {
|
|
||||||
Write-Host "$envName is not set"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
if (-not (Test-Path "$JavaVersionPath")) {
|
|
||||||
Write-Host "$envName path does not exist: $JavaVersionPath"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
Write-Host "$envName=$JavaVersionPath"
|
|
||||||
shell: pwsh
|
|
||||||
- name: Verify Java 21 outputs are set
|
|
||||||
run: |
|
|
||||||
echo "Java 21 path=${{ steps.setup-java-21.outputs.path }}"
|
|
||||||
echo "Java 21 version=${{ steps.setup-java-21.outputs.version }}"
|
|
||||||
if [ -z "${{ steps.setup-java-21.outputs.path }}" ]; then
|
|
||||||
echo "Java 21 path output should be set"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -z "${{ steps.setup-java-21.outputs.version }}" ]; then
|
|
||||||
echo "Java 21 version output should be set"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
shell: bash
|
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ For more details, see the full release notes on the [releases page](https://git
|
|||||||
|
|
||||||
- `java-version`: The Java version that is going to be set up. Takes a whole or [semver](#supported-version-syntax) Java version. If not specified, the action will expect `java-version-file` input to be specified.
|
- `java-version`: The Java version that is going to be set up. Takes a whole or [semver](#supported-version-syntax) Java version. If not specified, the action will expect `java-version-file` input to be specified.
|
||||||
|
|
||||||
- `java-version-file`: The path to a file containing java version. Supported file types are `.java-version`, `.tool-versions`, and `.sdkmanrc`. See more details in [about .java-version-file](docs/advanced-usage.md#Java-version-file).
|
- `java-version-file`: The path to a file containing java version. Supported file types are `.java-version` and `.tool-versions`. See more details in [about .java-version-file](docs/advanced-usage.md#Java-version-file).
|
||||||
|
|
||||||
- `distribution`: Java [distribution](#supported-distributions). Required unless `java-version-file` points to `.sdkmanrc` with a recognized distribution suffix (for example `java=21.0.5-tem`).
|
- `distribution`: _(required)_ Java [distribution](#supported-distributions).
|
||||||
|
|
||||||
- `java-package`: The packaging variant of the chosen distribution. Possible values: `jdk`, `jre`, `jdk+fx`, `jre+fx`. Default value: `jdk`.
|
- `java-package`: The packaging variant of the chosen distribution. Possible values: `jdk`, `jre`, `jdk+fx`, `jre+fx`. Default value: `jdk`.
|
||||||
|
|
||||||
@@ -41,8 +41,6 @@ For more details, see the full release notes on the [releases page](https://git
|
|||||||
|
|
||||||
- `check-latest`: Setting this option makes the action to check for the latest available version for the version spec.
|
- `check-latest`: Setting this option makes the action to check for the latest available version for the version spec.
|
||||||
|
|
||||||
- `set-default`: Set to `false` to install a JDK without making it the default. When `false`, `JAVA_HOME` and `PATH` are not updated, but `JAVA_HOME_<major>_<arch>` is still set so the JDK remains discoverable. Default value: `true`. See [Installing JDK without setting as default](docs/advanced-usage.md#Installing-JDK-without-setting-as-default) for more details.
|
|
||||||
|
|
||||||
- `verify-signature`: Verifies downloaded Java package signatures when supported by the selected distribution. Currently supported for `temurin` and `microsoft`. If set to `true` for unsupported distributions, the action fails.
|
- `verify-signature`: Verifies downloaded Java package signatures when supported by the selected distribution. Currently supported for `temurin` and `microsoft`. If set to `true` for unsupported distributions, the action fails.
|
||||||
|
|
||||||
- `verify-signature-public-key`: ASCII-armored GPG public key used to verify the downloaded package signature. Overrides the default bundled key for the selected distribution.
|
- `verify-signature-public-key`: ASCII-armored GPG public key used to verify the downloaded package signature. Overrides the default bundled key for the selected distribution.
|
||||||
@@ -147,8 +145,6 @@ The workflow output `cache-hit` is set to indicate if an exact match was found f
|
|||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
#### Caching gradle dependencies
|
#### Caching gradle dependencies
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
7.0.352-zulu, 7.0.352
|
7.0.352-zulu, 7.0.352
|
||||||
8.0.282-trava, 8.0.282
|
8.0.282-trava, 8.0.282
|
||||||
8.0.432-albba, 8.0.432
|
8.0.432-albba, 8.0.432
|
||||||
8.0.432-amzn, 8
|
8.0.432-amzn, 8.0.432
|
||||||
8.0.432-kona, 8.0.432
|
8.0.432-kona, 8.0.432
|
||||||
8.0.432-librca, 8.0.432
|
8.0.432-librca, 8.0.432
|
||||||
8.0.432-sem, 8.0.432
|
8.0.432-sem, 8.0.432
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
8.0.432-zulu, 8.0.432
|
8.0.432-zulu, 8.0.432
|
||||||
8.0.432.fx-librca, 8.0.432
|
8.0.432.fx-librca, 8.0.432
|
||||||
8.0.432.fx-zulu, 8.0.432
|
8.0.432.fx-zulu, 8.0.432
|
||||||
8.0.442-amzn, 8
|
8.0.442-amzn, 8.0.442
|
||||||
8.0.442-librca, 8.0.442
|
8.0.442-librca, 8.0.442
|
||||||
8.0.442-tem, 8.0.442
|
8.0.442-tem, 8.0.442
|
||||||
8.0.442-zulu, 8.0.442
|
8.0.442-zulu, 8.0.442
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
11.0.14.1-jbr, 11.0.14
|
11.0.14.1-jbr, 11.0.14
|
||||||
11.0.15-trava, 11.0.15
|
11.0.15-trava, 11.0.15
|
||||||
11.0.25-albba, 11.0.25
|
11.0.25-albba, 11.0.25
|
||||||
11.0.25-amzn, 11
|
11.0.25-amzn, 11.0.25
|
||||||
11.0.25-kona, 11.0.25
|
11.0.25-kona, 11.0.25
|
||||||
11.0.25-librca, 11.0.25
|
11.0.25-librca, 11.0.25
|
||||||
11.0.25-ms, 11.0.25
|
11.0.25-ms, 11.0.25
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
11.0.25-zulu, 11.0.25
|
11.0.25-zulu, 11.0.25
|
||||||
11.0.25.fx-librca, 11.0.25
|
11.0.25.fx-librca, 11.0.25
|
||||||
11.0.25.fx-zulu, 11.0.25
|
11.0.25.fx-zulu, 11.0.25
|
||||||
11.0.26-amzn, 11
|
11.0.26-amzn, 11.0.26
|
||||||
11.0.26-librca, 11.0.26
|
11.0.26-librca, 11.0.26
|
||||||
11.0.26-ms, 11.0.26
|
11.0.26-ms, 11.0.26
|
||||||
11.0.26-sapmchn, 11.0.26
|
11.0.26-sapmchn, 11.0.26
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
17.0.12-jbr, 17.0.12
|
17.0.12-jbr, 17.0.12
|
||||||
17.0.12-oracle, 17.0.12
|
17.0.12-oracle, 17.0.12
|
||||||
17.0.13-albba, 17.0.13
|
17.0.13-albba, 17.0.13
|
||||||
17.0.13-amzn, 17
|
17.0.13-amzn, 17.0.13
|
||||||
17.0.13-kona, 17.0.13
|
17.0.13-kona, 17.0.13
|
||||||
17.0.13-librca, 17.0.13
|
17.0.13-librca, 17.0.13
|
||||||
17.0.13-ms, 17.0.13
|
17.0.13-ms, 17.0.13
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
17.0.13.crac-zulu, 17.0.13
|
17.0.13.crac-zulu, 17.0.13
|
||||||
17.0.13.fx-librca, 17.0.13
|
17.0.13.fx-librca, 17.0.13
|
||||||
17.0.13.fx-zulu, 17.0.13
|
17.0.13.fx-zulu, 17.0.13
|
||||||
17.0.14-amzn, 17
|
17.0.14-amzn, 17.0.14
|
||||||
17.0.14-librca, 17.0.14
|
17.0.14-librca, 17.0.14
|
||||||
17.0.14-ms, 17.0.14
|
17.0.14-ms, 17.0.14
|
||||||
17.0.14-sapmchn, 17.0.14
|
17.0.14-sapmchn, 17.0.14
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
17.0.9-graalce, 17.0.9
|
17.0.9-graalce, 17.0.9
|
||||||
21.0.2-graalce, 21.0.2
|
21.0.2-graalce, 21.0.2
|
||||||
21.0.2-open, 21.0.2
|
21.0.2-open, 21.0.2
|
||||||
21.0.5-amzn, 21
|
21.0.5-amzn, 21.0.5
|
||||||
21.0.5-graal, 21.0.5
|
21.0.5-graal, 21.0.5
|
||||||
21.0.5-jbr, 21.0.5
|
21.0.5-jbr, 21.0.5
|
||||||
21.0.5-kona, 21.0.5
|
21.0.5-kona, 21.0.5
|
||||||
@@ -77,7 +77,7 @@
|
|||||||
21.0.5.crac-zulu, 21.0.5
|
21.0.5.crac-zulu, 21.0.5
|
||||||
21.0.5.fx-librca, 21.0.5
|
21.0.5.fx-librca, 21.0.5
|
||||||
21.0.5.fx-zulu, 21.0.5
|
21.0.5.fx-zulu, 21.0.5
|
||||||
21.0.6-amzn, 21
|
21.0.6-amzn, 21.0.6
|
||||||
21.0.6-graal, 21.0.6
|
21.0.6-graal, 21.0.6
|
||||||
21.0.6-librca, 21.0.6
|
21.0.6-librca, 21.0.6
|
||||||
21.0.6-ms, 21.0.6
|
21.0.6-ms, 21.0.6
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
22.3.5.r17-mandrel, 22.3.5
|
22.3.5.r17-mandrel, 22.3.5
|
||||||
22.3.5.r17-nik, 22.3.5
|
22.3.5.r17-nik, 22.3.5
|
||||||
23-open, 23
|
23-open, 23
|
||||||
23.0.1-amzn, 23
|
23.0.1-amzn, 23.0.1
|
||||||
23.0.1-graal, 23.0.1
|
23.0.1-graal, 23.0.1
|
||||||
23.0.1-graalce, 23.0.1
|
23.0.1-graalce, 23.0.1
|
||||||
23.0.1-librca, 23.0.1
|
23.0.1-librca, 23.0.1
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
23.0.1.crac-zulu, 23.0.1
|
23.0.1.crac-zulu, 23.0.1
|
||||||
23.0.1.fx-librca, 23.0.1
|
23.0.1.fx-librca, 23.0.1
|
||||||
23.0.1.fx-zulu, 23.0.1
|
23.0.1.fx-zulu, 23.0.1
|
||||||
23.0.2-amzn, 23
|
23.0.2-amzn, 23.0.2
|
||||||
23.0.2-graal, 23.0.2
|
23.0.2-graal, 23.0.2
|
||||||
23.0.2-graalce, 23.0.2
|
23.0.2-graalce, 23.0.2
|
||||||
23.0.2-librca, 23.0.2
|
23.0.2-librca, 23.0.2
|
||||||
|
|||||||
|
@@ -563,110 +563,6 @@ describe('setupJava', () => {
|
|||||||
expect(spyCoreExportVariable).not.toHaveBeenCalled();
|
expect(spyCoreExportVariable).not.toHaveBeenCalled();
|
||||||
expect(spyCoreSetOutput).not.toHaveBeenCalled();
|
expect(spyCoreSetOutput).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not set JAVA_HOME and PATH when setDefault is false', async () => {
|
|
||||||
mockJavaBase = new EmptyJavaBase({
|
|
||||||
version: '11',
|
|
||||||
architecture: 'x86',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false,
|
|
||||||
setDefault: false
|
|
||||||
});
|
|
||||||
await expect(mockJavaBase.setupJava()).resolves.toEqual({
|
|
||||||
version: installedJavaVersion,
|
|
||||||
path: javaPath
|
|
||||||
});
|
|
||||||
expect(spyCoreExportVariable).not.toHaveBeenCalledWith(
|
|
||||||
'JAVA_HOME',
|
|
||||||
expect.anything()
|
|
||||||
);
|
|
||||||
expect(spyCoreAddPath).not.toHaveBeenCalled();
|
|
||||||
expect(spyCoreExportVariable).toHaveBeenCalledWith(
|
|
||||||
'JAVA_HOME_11_X86',
|
|
||||||
javaPath
|
|
||||||
);
|
|
||||||
expect(spyCoreSetOutput).toHaveBeenCalledWith(
|
|
||||||
'version',
|
|
||||||
installedJavaVersion
|
|
||||||
);
|
|
||||||
expect(spyCoreSetOutput).toHaveBeenCalledWith('path', javaPath);
|
|
||||||
expect(spyCoreSetOutput).toHaveBeenCalledWith('distribution', 'Empty');
|
|
||||||
expect(spyCoreInfo).toHaveBeenCalledWith(
|
|
||||||
`Installing Java ${installedJavaVersion} (not setting as default)`
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set JAVA_HOME and PATH when setDefault is true', async () => {
|
|
||||||
mockJavaBase = new EmptyJavaBase({
|
|
||||||
version: '11',
|
|
||||||
architecture: 'x86',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false,
|
|
||||||
setDefault: true
|
|
||||||
});
|
|
||||||
await expect(mockJavaBase.setupJava()).resolves.toEqual({
|
|
||||||
version: installedJavaVersion,
|
|
||||||
path: javaPath
|
|
||||||
});
|
|
||||||
expect(spyCoreExportVariable).toHaveBeenCalledWith('JAVA_HOME', javaPath);
|
|
||||||
expect(spyCoreAddPath).toHaveBeenCalledWith(path.join(javaPath, 'bin'));
|
|
||||||
expect(spyCoreExportVariable).toHaveBeenCalledWith(
|
|
||||||
'JAVA_HOME_11_X86',
|
|
||||||
javaPath
|
|
||||||
);
|
|
||||||
expect(spyCoreInfo).toHaveBeenCalledWith(
|
|
||||||
`Setting Java ${installedJavaVersion} as the default`
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should default to setting as default when setDefault is not specified', async () => {
|
|
||||||
mockJavaBase = new EmptyJavaBase({
|
|
||||||
version: '11',
|
|
||||||
architecture: 'x86',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false
|
|
||||||
});
|
|
||||||
await expect(mockJavaBase.setupJava()).resolves.toEqual({
|
|
||||||
version: installedJavaVersion,
|
|
||||||
path: javaPath
|
|
||||||
});
|
|
||||||
expect(spyCoreExportVariable).toHaveBeenCalledWith('JAVA_HOME', javaPath);
|
|
||||||
expect(spyCoreAddPath).toHaveBeenCalledWith(path.join(javaPath, 'bin'));
|
|
||||||
expect(spyCoreInfo).toHaveBeenCalledWith(
|
|
||||||
`Setting Java ${installedJavaVersion} as the default`
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should download and not set default when setDefault is false', async () => {
|
|
||||||
mockJavaBase = new EmptyJavaBase({
|
|
||||||
version: '11',
|
|
||||||
architecture: 'x64',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false,
|
|
||||||
setDefault: false
|
|
||||||
});
|
|
||||||
await expect(mockJavaBase.setupJava()).resolves.toEqual({
|
|
||||||
version: '11.0.9',
|
|
||||||
path: path.join('toolcache', 'Java_Empty_jdk', '11.0.9', 'x64')
|
|
||||||
});
|
|
||||||
expect(spyCoreExportVariable).not.toHaveBeenCalledWith(
|
|
||||||
'JAVA_HOME',
|
|
||||||
expect.anything()
|
|
||||||
);
|
|
||||||
expect(spyCoreAddPath).not.toHaveBeenCalled();
|
|
||||||
expect(spyCoreExportVariable).toHaveBeenCalledWith(
|
|
||||||
'JAVA_HOME_11_X64',
|
|
||||||
path.join('toolcache', 'Java_Empty_jdk', '11.0.9', 'x64')
|
|
||||||
);
|
|
||||||
expect(spyCoreSetOutput).toHaveBeenCalledWith('version', '11.0.9');
|
|
||||||
expect(spyCoreSetOutput).toHaveBeenCalledWith(
|
|
||||||
'path',
|
|
||||||
path.join('toolcache', 'Java_Empty_jdk', '11.0.9', 'x64')
|
|
||||||
);
|
|
||||||
expect(spyCoreInfo).toHaveBeenCalledWith(
|
|
||||||
'Installing Java 11.0.9 (not setting as default)'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('normalizeVersion', () => {
|
describe('normalizeVersion', () => {
|
||||||
|
|||||||
+10
-55
@@ -166,60 +166,15 @@ describe('validatePaginationUrl', () => {
|
|||||||
describe('getVersionFromFileContent', () => {
|
describe('getVersionFromFileContent', () => {
|
||||||
describe('.sdkmanrc', () => {
|
describe('.sdkmanrc', () => {
|
||||||
it.each([
|
it.each([
|
||||||
['java=11.0.20.1-tem', '11.0.20', 'temurin'],
|
['java=11.0.20.1-tem', '11.0.20'],
|
||||||
['java = 11.0.20.1-tem', '11.0.20', 'temurin'],
|
['java = 11.0.20.1-tem', '11.0.20'],
|
||||||
['java=11.0.20.1-tem # a comment in sdkmanrc', '11.0.20', 'temurin'],
|
['java=11.0.20.1-tem # a comment in sdkmanrc', '11.0.20'],
|
||||||
['java=11.0.20.1-tem\n#java=21.0.20.1-tem\n', '11.0.20', 'temurin'], // choose first match
|
['java=11.0.20.1-tem\n#java=21.0.20.1-tem\n', '11.0.20'], // choose first match
|
||||||
['java=11.0.20.1-tem\njava=21.0.20.1-tem\n', '11.0.20', 'temurin'], // choose first match
|
['java=11.0.20.1-tem\njava=21.0.20.1-tem\n', '11.0.20'], // choose first match
|
||||||
['#java=11.0.20.1-tem\njava=21.0.20.1-tem\n', '21.0.20', 'temurin'], // first one is 'commented' in .sdkmanrc
|
['#java=11.0.20.1-tem\njava=21.0.20.1-tem\n', '21.0.20'] // first one is 'commented' in .sdkmanrc
|
||||||
['java=21.0.5-zulu', '21.0.5', 'zulu'],
|
])('parsing %s should return %s', (content: string, expected: string) => {
|
||||||
['java=17.0.13-albba', '17.0.13', 'dragonwell'],
|
const actual = getVersionFromFileContent(content, 'openjdk', '.sdkmanrc');
|
||||||
['java=17.0.13-amzn', '17', 'corretto'],
|
expect(actual).toBe(expected);
|
||||||
['java=21.0.5-graal', '21.0.5', 'graalvm'],
|
|
||||||
['java=17.0.9-graalce', '17.0.9', 'graalvm'],
|
|
||||||
['java=11.0.25-librca', '11.0.25', 'liberica'],
|
|
||||||
['java=11.0.25-ms', '11.0.25', 'microsoft'],
|
|
||||||
['java=21.0.5-oracle', '21.0.5', 'oracle'],
|
|
||||||
['java=11.0.25-sapmchn', '11.0.25', 'sapmachine'],
|
|
||||||
['java=21.0.5-jbr', '21.0.5', 'jetbrains'],
|
|
||||||
['java=11.0.25-sem', '11.0.25', 'semeru'],
|
|
||||||
['java=17.0.13-dragonwell', '17.0.13', 'dragonwell'],
|
|
||||||
['java=21.0.5-kona', '21.0.5', 'kona']
|
|
||||||
])(
|
|
||||||
'parsing %s should return version %s and distribution %s',
|
|
||||||
(content: string, expectedVersion: string, expectedDist: string) => {
|
|
||||||
const actual = getVersionFromFileContent(
|
|
||||||
content,
|
|
||||||
'openjdk',
|
|
||||||
'.sdkmanrc'
|
|
||||||
);
|
|
||||||
expect(actual?.version).toBe(expectedVersion);
|
|
||||||
expect(actual?.distribution).toBe(expectedDist);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
it('should warn and return undefined distribution for unknown identifier', () => {
|
|
||||||
const warnSpy = jest.spyOn(core, 'warning');
|
|
||||||
const actual = getVersionFromFileContent(
|
|
||||||
'java=21.0.5-unknown',
|
|
||||||
'temurin',
|
|
||||||
'.sdkmanrc'
|
|
||||||
);
|
|
||||||
expect(actual?.version).toBe('21.0.5');
|
|
||||||
expect(actual?.distribution).toBeUndefined();
|
|
||||||
expect(warnSpy).toHaveBeenCalledWith(
|
|
||||||
expect.stringContaining('Unknown SDKMAN distribution identifier')
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return version without distribution when no suffix provided', () => {
|
|
||||||
const actual = getVersionFromFileContent(
|
|
||||||
'java=11.0.20',
|
|
||||||
'temurin',
|
|
||||||
'.sdkmanrc'
|
|
||||||
);
|
|
||||||
expect(actual?.version).toBe('11.0.20');
|
|
||||||
expect(actual?.distribution).toBeUndefined();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('known versions', () => {
|
describe('known versions', () => {
|
||||||
@@ -238,7 +193,7 @@ describe('getVersionFromFileContent', () => {
|
|||||||
'openjdk',
|
'openjdk',
|
||||||
'.sdkmanrc'
|
'.sdkmanrc'
|
||||||
);
|
);
|
||||||
expect(actual?.version).toBe(expected);
|
expect(actual).toBe(expected);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-6
@@ -10,8 +10,8 @@ inputs:
|
|||||||
description: 'The path to a file containing the Java version to set up (.java-version, .tool-versions, .sdkmanrc). Used when java-version is not set. See examples of supported syntax in README file'
|
description: 'The path to a file containing the Java version to set up (.java-version, .tool-versions, .sdkmanrc). Used when java-version is not set. See examples of supported syntax in README file'
|
||||||
required: false
|
required: false
|
||||||
distribution:
|
distribution:
|
||||||
description: 'Java distribution. See the list of supported distributions in README file. This input is required except when java-version-file points to .sdkmanrc with a recognized distribution suffix (e.g., java=21.0.5-tem).'
|
description: 'Java distribution. See the list of supported distributions in README file'
|
||||||
required: false
|
required: true
|
||||||
java-package:
|
java-package:
|
||||||
description: 'The package type (jdk, jre, jdk+fx, jre+fx)'
|
description: 'The package type (jdk, jre, jdk+fx, jre+fx)'
|
||||||
required: false
|
required: false
|
||||||
@@ -26,10 +26,6 @@ inputs:
|
|||||||
description: 'Set this option if you want the action to check for the latest available version that satisfies the version spec'
|
description: 'Set this option if you want the action to check for the latest available version that satisfies the version spec'
|
||||||
required: false
|
required: false
|
||||||
default: false
|
default: false
|
||||||
set-default:
|
|
||||||
description: 'Set this option to false if you want to install a JDK but not make it the default. When false, JAVA_HOME and PATH are not updated, but JAVA_HOME_<major>_<arch> is still set.'
|
|
||||||
required: false
|
|
||||||
default: true
|
|
||||||
verify-signature:
|
verify-signature:
|
||||||
description: 'Verify downloaded Java package signatures when supported by the selected distribution'
|
description: 'Verify downloaded Java package signatures when supported by the selected distribution'
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
Vendored
+8
-48
@@ -52241,7 +52241,7 @@ else {
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG = exports.MAVEN_NO_TRANSFER_PROGRESS_FLAG = exports.MAVEN_ARGS_ENV = exports.INPUT_SHOW_DOWNLOAD_PROGRESS = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_VERIFY_SIGNATURE_PUBLIC_KEY = exports.INPUT_VERIFY_SIGNATURE = exports.INPUT_SET_DEFAULT = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
|
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG = exports.MAVEN_NO_TRANSFER_PROGRESS_FLAG = exports.MAVEN_ARGS_ENV = exports.INPUT_SHOW_DOWNLOAD_PROGRESS = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_VERIFY_SIGNATURE_PUBLIC_KEY = exports.INPUT_VERIFY_SIGNATURE = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
|
||||||
exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
|
exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
|
||||||
exports.INPUT_JAVA_VERSION = 'java-version';
|
exports.INPUT_JAVA_VERSION = 'java-version';
|
||||||
exports.INPUT_JAVA_VERSION_FILE = 'java-version-file';
|
exports.INPUT_JAVA_VERSION_FILE = 'java-version-file';
|
||||||
@@ -52250,7 +52250,6 @@ exports.INPUT_JAVA_PACKAGE = 'java-package';
|
|||||||
exports.INPUT_DISTRIBUTION = 'distribution';
|
exports.INPUT_DISTRIBUTION = 'distribution';
|
||||||
exports.INPUT_JDK_FILE = 'jdkFile';
|
exports.INPUT_JDK_FILE = 'jdkFile';
|
||||||
exports.INPUT_CHECK_LATEST = 'check-latest';
|
exports.INPUT_CHECK_LATEST = 'check-latest';
|
||||||
exports.INPUT_SET_DEFAULT = 'set-default';
|
|
||||||
exports.INPUT_VERIFY_SIGNATURE = 'verify-signature';
|
exports.INPUT_VERIFY_SIGNATURE = 'verify-signature';
|
||||||
exports.INPUT_VERIFY_SIGNATURE_PUBLIC_KEY = 'verify-signature-public-key';
|
exports.INPUT_VERIFY_SIGNATURE_PUBLIC_KEY = 'verify-signature-public-key';
|
||||||
exports.INPUT_SERVER_ID = 'server-id';
|
exports.INPUT_SERVER_ID = 'server-id';
|
||||||
@@ -52572,9 +52571,8 @@ function isCacheFeatureAvailable() {
|
|||||||
}
|
}
|
||||||
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
||||||
function getVersionFromFileContent(content, distributionName, versionFile) {
|
function getVersionFromFileContent(content, distributionName, versionFile) {
|
||||||
var _a, _b, _c;
|
var _a, _b, _c, _d, _e;
|
||||||
let javaVersionRegExp;
|
let javaVersionRegExp;
|
||||||
let extractedDistribution;
|
|
||||||
function getFileName(versionFile) {
|
function getFileName(versionFile) {
|
||||||
return path_1.default.basename(versionFile);
|
return path_1.default.basename(versionFile);
|
||||||
}
|
}
|
||||||
@@ -52584,23 +52582,14 @@ function getVersionFromFileContent(content, distributionName, versionFile) {
|
|||||||
/^java\s+(?:\S*-)?(?<version>\d+(?:\.\d+)*([+_.-](?:openj9[-._]?\d[\w.-]*|java\d+|jre[-_\w]*|OpenJDK\d+[\w_.-]*|[a-z0-9]+))*)/im;
|
/^java\s+(?:\S*-)?(?<version>\d+(?:\.\d+)*([+_.-](?:openj9[-._]?\d[\w.-]*|java\d+|jre[-_\w]*|OpenJDK\d+[\w_.-]*|[a-z0-9]+))*)/im;
|
||||||
}
|
}
|
||||||
else if (versionFileName == '.sdkmanrc') {
|
else if (versionFileName == '.sdkmanrc') {
|
||||||
// Match both version and optional distribution identifier
|
javaVersionRegExp = /^java\s*=\s*(?<version>[^-]+)/m;
|
||||||
javaVersionRegExp =
|
|
||||||
/^java\s*=\s*(?<version>[^-\s]+)(?:-(?<distribution>[a-z0-9]+))?/m;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
||||||
}
|
}
|
||||||
const match = content.match(javaVersionRegExp);
|
const capturedVersion = ((_b = (_a = content.match(javaVersionRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version)
|
||||||
const capturedVersion = ((_a = match === null || match === void 0 ? void 0 : match.groups) === null || _a === void 0 ? void 0 : _a.version)
|
? (_d = (_c = content.match(javaVersionRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version
|
||||||
? match.groups.version
|
|
||||||
: '';
|
: '';
|
||||||
// Extract distribution from .sdkmanrc file
|
|
||||||
if (versionFileName == '.sdkmanrc' && ((_b = match === null || match === void 0 ? void 0 : match.groups) === null || _b === void 0 ? void 0 : _b.distribution)) {
|
|
||||||
const sdkmanDist = match.groups.distribution;
|
|
||||||
extractedDistribution = mapSdkmanDistribution(sdkmanDist);
|
|
||||||
core.debug(`Parsed distribution '${extractedDistribution}' from SDKMAN identifier '${sdkmanDist}'`);
|
|
||||||
}
|
|
||||||
core.debug(`Parsed version '${capturedVersion}' from file '${versionFileName}'`);
|
core.debug(`Parsed version '${capturedVersion}' from file '${versionFileName}'`);
|
||||||
if (!capturedVersion) {
|
if (!capturedVersion) {
|
||||||
return null;
|
return null;
|
||||||
@@ -52614,42 +52603,13 @@ function getVersionFromFileContent(content, distributionName, versionFile) {
|
|||||||
if (!version) {
|
if (!version) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// Apply DISTRIBUTIONS_ONLY_MAJOR_VERSION logic whenever the effective distribution
|
if (constants_1.DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(distributionName)) {
|
||||||
// (either explicitly provided or extracted from the version file) is in the list.
|
const coerceVersion = (_e = semver.coerce(version)) !== null && _e !== void 0 ? _e : version;
|
||||||
if (constants_1.DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(extractedDistribution || distributionName)) {
|
|
||||||
const coerceVersion = (_c = semver.coerce(version)) !== null && _c !== void 0 ? _c : version;
|
|
||||||
version = semver.major(coerceVersion).toString();
|
version = semver.major(coerceVersion).toString();
|
||||||
}
|
}
|
||||||
return {
|
return version.toString();
|
||||||
version: version.toString(),
|
|
||||||
distribution: extractedDistribution
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
exports.getVersionFromFileContent = getVersionFromFileContent;
|
exports.getVersionFromFileContent = getVersionFromFileContent;
|
||||||
// Map SDKMAN distribution identifiers to setup-java distribution names
|
|
||||||
function mapSdkmanDistribution(sdkmanDist) {
|
|
||||||
const distributionMap = {
|
|
||||||
tem: 'temurin',
|
|
||||||
sem: 'semeru',
|
|
||||||
albba: 'dragonwell',
|
|
||||||
zulu: 'zulu',
|
|
||||||
amzn: 'corretto',
|
|
||||||
graal: 'graalvm',
|
|
||||||
graalce: 'graalvm',
|
|
||||||
librca: 'liberica',
|
|
||||||
ms: 'microsoft',
|
|
||||||
oracle: 'oracle',
|
|
||||||
sapmchn: 'sapmachine',
|
|
||||||
jbr: 'jetbrains',
|
|
||||||
dragonwell: 'dragonwell',
|
|
||||||
kona: 'kona'
|
|
||||||
};
|
|
||||||
const mapped = distributionMap[sdkmanDist.toLowerCase()];
|
|
||||||
if (!mapped) {
|
|
||||||
core.warning(`Unknown SDKMAN distribution identifier '${sdkmanDist}'. Please specify the distribution explicitly.`);
|
|
||||||
}
|
|
||||||
return mapped;
|
|
||||||
}
|
|
||||||
// By convention, action expects version 8 in the format `8.*` instead of `1.8`
|
// By convention, action expects version 8 in the format `8.*` instead of `1.8`
|
||||||
function avoidOldNotation(content) {
|
function avoidOldNotation(content) {
|
||||||
return content.startsWith('1.') ? content.substring(2) : content;
|
return content.startsWith('1.') ? content.substring(2) : content;
|
||||||
|
|||||||
Vendored
+33
-118
@@ -78001,7 +78001,7 @@ function isProbablyGradleDaemonProblem(packageManager, error) {
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG = exports.MAVEN_NO_TRANSFER_PROGRESS_FLAG = exports.MAVEN_ARGS_ENV = exports.INPUT_SHOW_DOWNLOAD_PROGRESS = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_VERIFY_SIGNATURE_PUBLIC_KEY = exports.INPUT_VERIFY_SIGNATURE = exports.INPUT_SET_DEFAULT = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
|
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG = exports.MAVEN_NO_TRANSFER_PROGRESS_FLAG = exports.MAVEN_ARGS_ENV = exports.INPUT_SHOW_DOWNLOAD_PROGRESS = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_VERIFY_SIGNATURE_PUBLIC_KEY = exports.INPUT_VERIFY_SIGNATURE = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
|
||||||
exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
|
exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
|
||||||
exports.INPUT_JAVA_VERSION = 'java-version';
|
exports.INPUT_JAVA_VERSION = 'java-version';
|
||||||
exports.INPUT_JAVA_VERSION_FILE = 'java-version-file';
|
exports.INPUT_JAVA_VERSION_FILE = 'java-version-file';
|
||||||
@@ -78010,7 +78010,6 @@ exports.INPUT_JAVA_PACKAGE = 'java-package';
|
|||||||
exports.INPUT_DISTRIBUTION = 'distribution';
|
exports.INPUT_DISTRIBUTION = 'distribution';
|
||||||
exports.INPUT_JDK_FILE = 'jdkFile';
|
exports.INPUT_JDK_FILE = 'jdkFile';
|
||||||
exports.INPUT_CHECK_LATEST = 'check-latest';
|
exports.INPUT_CHECK_LATEST = 'check-latest';
|
||||||
exports.INPUT_SET_DEFAULT = 'set-default';
|
|
||||||
exports.INPUT_VERIFY_SIGNATURE = 'verify-signature';
|
exports.INPUT_VERIFY_SIGNATURE = 'verify-signature';
|
||||||
exports.INPUT_VERIFY_SIGNATURE_PUBLIC_KEY = 'verify-signature-public-key';
|
exports.INPUT_VERIFY_SIGNATURE_PUBLIC_KEY = 'verify-signature-public-key';
|
||||||
exports.INPUT_SERVER_ID = 'server-id';
|
exports.INPUT_SERVER_ID = 'server-id';
|
||||||
@@ -78326,10 +78325,6 @@ class JavaBase {
|
|||||||
this.architecture = installerOptions.architecture || os_1.default.arch();
|
this.architecture = installerOptions.architecture || os_1.default.arch();
|
||||||
this.packageType = installerOptions.packageType;
|
this.packageType = installerOptions.packageType;
|
||||||
this.checkLatest = installerOptions.checkLatest;
|
this.checkLatest = installerOptions.checkLatest;
|
||||||
this.setDefault =
|
|
||||||
installerOptions.setDefault !== undefined
|
|
||||||
? installerOptions.setDefault
|
|
||||||
: true;
|
|
||||||
this.verifySignature = (_a = installerOptions.verifySignature) !== null && _a !== void 0 ? _a : false;
|
this.verifySignature = (_a = installerOptions.verifySignature) !== null && _a !== void 0 ? _a : false;
|
||||||
this.verifySignaturePublicKey = installerOptions.verifySignaturePublicKey;
|
this.verifySignaturePublicKey = installerOptions.verifySignaturePublicKey;
|
||||||
}
|
}
|
||||||
@@ -78450,14 +78445,8 @@ class JavaBase {
|
|||||||
if (process.platform === 'darwin' && fs.existsSync(macOSPostfixPath)) {
|
if (process.platform === 'darwin' && fs.existsSync(macOSPostfixPath)) {
|
||||||
foundJava.path = macOSPostfixPath;
|
foundJava.path = macOSPostfixPath;
|
||||||
}
|
}
|
||||||
if (this.setDefault) {
|
core.info(`Setting Java ${foundJava.version} as the default`);
|
||||||
core.info(`Setting Java ${foundJava.version} as the default`);
|
this.setJavaDefault(foundJava.version, foundJava.path);
|
||||||
this.setJavaDefault(foundJava.version, foundJava.path);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
core.info(`Installing Java ${foundJava.version} (not setting as default)`);
|
|
||||||
this.setJavaEnvironment(foundJava.version, foundJava.path);
|
|
||||||
}
|
|
||||||
return foundJava;
|
return foundJava;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -78558,12 +78547,9 @@ class JavaBase {
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
setJavaDefault(version, toolPath) {
|
setJavaDefault(version, toolPath) {
|
||||||
|
const majorVersion = version.split('.')[0];
|
||||||
core.exportVariable('JAVA_HOME', toolPath);
|
core.exportVariable('JAVA_HOME', toolPath);
|
||||||
core.addPath(path_1.default.join(toolPath, 'bin'));
|
core.addPath(path_1.default.join(toolPath, 'bin'));
|
||||||
this.setJavaEnvironment(version, toolPath);
|
|
||||||
}
|
|
||||||
setJavaEnvironment(version, toolPath) {
|
|
||||||
const majorVersion = version.split('.')[0];
|
|
||||||
core.setOutput('distribution', this.distribution);
|
core.setOutput('distribution', this.distribution);
|
||||||
core.setOutput('path', toolPath);
|
core.setOutput('path', toolPath);
|
||||||
core.setOutput('version', version);
|
core.setOutput('version', version);
|
||||||
@@ -80062,14 +80048,8 @@ class LocalDistribution extends base_installer_1.JavaBase {
|
|||||||
if (process.platform === 'darwin' && fs_1.default.existsSync(macOSPostfixPath)) {
|
if (process.platform === 'darwin' && fs_1.default.existsSync(macOSPostfixPath)) {
|
||||||
foundJava.path = macOSPostfixPath;
|
foundJava.path = macOSPostfixPath;
|
||||||
}
|
}
|
||||||
if (this.setDefault) {
|
core.info(`Setting Java ${foundJava.version} as default`);
|
||||||
core.info(`Setting Java ${foundJava.version} as the default`);
|
this.setJavaDefault(foundJava.version, foundJava.path);
|
||||||
this.setJavaDefault(foundJava.version, foundJava.path);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
core.info(`Installing Java ${foundJava.version} (not setting as default)`);
|
|
||||||
this.setJavaEnvironment(foundJava.version, foundJava.path);
|
|
||||||
}
|
|
||||||
return foundJava;
|
return foundJava;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -81542,7 +81522,9 @@ function run() {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION);
|
const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION);
|
||||||
let distributionName = core.getInput(constants.INPUT_DISTRIBUTION);
|
const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, {
|
||||||
|
required: true
|
||||||
|
});
|
||||||
const versionFile = core.getInput(constants.INPUT_JAVA_VERSION_FILE);
|
const versionFile = core.getInput(constants.INPUT_JAVA_VERSION_FILE);
|
||||||
const architecture = core.getInput(constants.INPUT_ARCHITECTURE);
|
const architecture = core.getInput(constants.INPUT_ARCHITECTURE);
|
||||||
const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
|
const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
|
||||||
@@ -81550,7 +81532,6 @@ function run() {
|
|||||||
const cache = core.getInput(constants.INPUT_CACHE);
|
const cache = core.getInput(constants.INPUT_CACHE);
|
||||||
const cacheDependencyPath = core.getInput(constants.INPUT_CACHE_DEPENDENCY_PATH);
|
const cacheDependencyPath = core.getInput(constants.INPUT_CACHE_DEPENDENCY_PATH);
|
||||||
const checkLatest = (0, util_1.getBooleanInput)(constants.INPUT_CHECK_LATEST, false);
|
const checkLatest = (0, util_1.getBooleanInput)(constants.INPUT_CHECK_LATEST, false);
|
||||||
const setDefault = (0, util_1.getBooleanInput)(constants.INPUT_SET_DEFAULT, true);
|
|
||||||
const verifySignature = (0, util_1.getBooleanInput)(constants.INPUT_VERIFY_SIGNATURE, false);
|
const verifySignature = (0, util_1.getBooleanInput)(constants.INPUT_VERIFY_SIGNATURE, false);
|
||||||
const verifySignaturePublicKey = core.getInput(constants.INPUT_VERIFY_SIGNATURE_PUBLIC_KEY) || undefined;
|
const verifySignaturePublicKey = core.getInput(constants.INPUT_VERIFY_SIGNATURE_PUBLIC_KEY) || undefined;
|
||||||
let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID);
|
let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID);
|
||||||
@@ -81561,54 +81542,28 @@ function run() {
|
|||||||
if (!versions.length && !versionFile) {
|
if (!versions.length && !versionFile) {
|
||||||
throw new Error('java-version or java-version-file input expected');
|
throw new Error('java-version or java-version-file input expected');
|
||||||
}
|
}
|
||||||
|
const installerInputsOptions = {
|
||||||
|
architecture,
|
||||||
|
packageType,
|
||||||
|
checkLatest,
|
||||||
|
verifySignature,
|
||||||
|
verifySignaturePublicKey,
|
||||||
|
distributionName,
|
||||||
|
jdkFile,
|
||||||
|
toolchainIds
|
||||||
|
};
|
||||||
if (!versions.length) {
|
if (!versions.length) {
|
||||||
core.debug('java-version input is empty, looking for java-version-file input');
|
core.debug('java-version input is empty, looking for java-version-file input');
|
||||||
const content = fs_1.default.readFileSync(versionFile).toString().trim();
|
const content = fs_1.default.readFileSync(versionFile).toString().trim();
|
||||||
const versionInfo = (0, util_1.getVersionFromFileContent)(content, distributionName, versionFile);
|
const version = (0, util_1.getVersionFromFileContent)(content, distributionName, versionFile);
|
||||||
core.debug(`Parsed version from file '${versionInfo === null || versionInfo === void 0 ? void 0 : versionInfo.version}'`);
|
core.debug(`Parsed version from file '${version}'`);
|
||||||
if (!versionInfo) {
|
if (!version) {
|
||||||
throw new Error(`No supported version was found in file ${versionFile}`);
|
throw new Error(`No supported version was found in file ${versionFile}`);
|
||||||
}
|
}
|
||||||
// Use distribution from file if available, otherwise use the input
|
yield installVersion(version, installerInputsOptions);
|
||||||
if (versionInfo.distribution) {
|
|
||||||
core.info(`Using distribution '${versionInfo.distribution}' from ${versionFile}`);
|
|
||||||
distributionName = versionInfo.distribution;
|
|
||||||
}
|
|
||||||
else if (!distributionName) {
|
|
||||||
throw new Error('distribution input is required when not specified in the version file');
|
|
||||||
}
|
|
||||||
const installerInputsOptions = {
|
|
||||||
architecture,
|
|
||||||
packageType,
|
|
||||||
checkLatest,
|
|
||||||
setDefault,
|
|
||||||
verifySignature,
|
|
||||||
verifySignaturePublicKey,
|
|
||||||
distributionName,
|
|
||||||
jdkFile,
|
|
||||||
toolchainIds
|
|
||||||
};
|
|
||||||
yield installVersion(versionInfo.version, installerInputsOptions);
|
|
||||||
}
|
}
|
||||||
else {
|
for (const [index, version] of versions.entries()) {
|
||||||
// When using java-version input, distribution is still required
|
yield installVersion(version, installerInputsOptions, index);
|
||||||
if (!distributionName) {
|
|
||||||
throw new Error('distribution input is required');
|
|
||||||
}
|
|
||||||
const installerInputsOptions = {
|
|
||||||
architecture,
|
|
||||||
packageType,
|
|
||||||
checkLatest,
|
|
||||||
setDefault,
|
|
||||||
verifySignature,
|
|
||||||
verifySignaturePublicKey,
|
|
||||||
distributionName,
|
|
||||||
jdkFile,
|
|
||||||
toolchainIds
|
|
||||||
};
|
|
||||||
for (const [index, version] of versions.entries()) {
|
|
||||||
yield installVersion(version, installerInputsOptions, index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
const matchersPath = path.join(__dirname, '..', '..', '.github');
|
const matchersPath = path.join(__dirname, '..', '..', '.github');
|
||||||
@@ -81627,12 +81582,11 @@ function run() {
|
|||||||
run();
|
run();
|
||||||
function installVersion(version, options, toolchainId = 0) {
|
function installVersion(version, options, toolchainId = 0) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const { distributionName, jdkFile, architecture, packageType, checkLatest, setDefault, verifySignature, verifySignaturePublicKey, toolchainIds } = options;
|
const { distributionName, jdkFile, architecture, packageType, checkLatest, verifySignature, verifySignaturePublicKey, toolchainIds } = options;
|
||||||
const installerOptions = {
|
const installerOptions = {
|
||||||
architecture,
|
architecture,
|
||||||
packageType,
|
packageType,
|
||||||
checkLatest,
|
checkLatest,
|
||||||
setDefault,
|
|
||||||
verifySignature,
|
verifySignature,
|
||||||
verifySignaturePublicKey,
|
verifySignaturePublicKey,
|
||||||
version
|
version
|
||||||
@@ -81990,9 +81944,8 @@ function isCacheFeatureAvailable() {
|
|||||||
}
|
}
|
||||||
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
||||||
function getVersionFromFileContent(content, distributionName, versionFile) {
|
function getVersionFromFileContent(content, distributionName, versionFile) {
|
||||||
var _a, _b, _c;
|
var _a, _b, _c, _d, _e;
|
||||||
let javaVersionRegExp;
|
let javaVersionRegExp;
|
||||||
let extractedDistribution;
|
|
||||||
function getFileName(versionFile) {
|
function getFileName(versionFile) {
|
||||||
return path_1.default.basename(versionFile);
|
return path_1.default.basename(versionFile);
|
||||||
}
|
}
|
||||||
@@ -82002,23 +81955,14 @@ function getVersionFromFileContent(content, distributionName, versionFile) {
|
|||||||
/^java\s+(?:\S*-)?(?<version>\d+(?:\.\d+)*([+_.-](?:openj9[-._]?\d[\w.-]*|java\d+|jre[-_\w]*|OpenJDK\d+[\w_.-]*|[a-z0-9]+))*)/im;
|
/^java\s+(?:\S*-)?(?<version>\d+(?:\.\d+)*([+_.-](?:openj9[-._]?\d[\w.-]*|java\d+|jre[-_\w]*|OpenJDK\d+[\w_.-]*|[a-z0-9]+))*)/im;
|
||||||
}
|
}
|
||||||
else if (versionFileName == '.sdkmanrc') {
|
else if (versionFileName == '.sdkmanrc') {
|
||||||
// Match both version and optional distribution identifier
|
javaVersionRegExp = /^java\s*=\s*(?<version>[^-]+)/m;
|
||||||
javaVersionRegExp =
|
|
||||||
/^java\s*=\s*(?<version>[^-\s]+)(?:-(?<distribution>[a-z0-9]+))?/m;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
||||||
}
|
}
|
||||||
const match = content.match(javaVersionRegExp);
|
const capturedVersion = ((_b = (_a = content.match(javaVersionRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version)
|
||||||
const capturedVersion = ((_a = match === null || match === void 0 ? void 0 : match.groups) === null || _a === void 0 ? void 0 : _a.version)
|
? (_d = (_c = content.match(javaVersionRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version
|
||||||
? match.groups.version
|
|
||||||
: '';
|
: '';
|
||||||
// Extract distribution from .sdkmanrc file
|
|
||||||
if (versionFileName == '.sdkmanrc' && ((_b = match === null || match === void 0 ? void 0 : match.groups) === null || _b === void 0 ? void 0 : _b.distribution)) {
|
|
||||||
const sdkmanDist = match.groups.distribution;
|
|
||||||
extractedDistribution = mapSdkmanDistribution(sdkmanDist);
|
|
||||||
core.debug(`Parsed distribution '${extractedDistribution}' from SDKMAN identifier '${sdkmanDist}'`);
|
|
||||||
}
|
|
||||||
core.debug(`Parsed version '${capturedVersion}' from file '${versionFileName}'`);
|
core.debug(`Parsed version '${capturedVersion}' from file '${versionFileName}'`);
|
||||||
if (!capturedVersion) {
|
if (!capturedVersion) {
|
||||||
return null;
|
return null;
|
||||||
@@ -82032,42 +81976,13 @@ function getVersionFromFileContent(content, distributionName, versionFile) {
|
|||||||
if (!version) {
|
if (!version) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// Apply DISTRIBUTIONS_ONLY_MAJOR_VERSION logic whenever the effective distribution
|
if (constants_1.DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(distributionName)) {
|
||||||
// (either explicitly provided or extracted from the version file) is in the list.
|
const coerceVersion = (_e = semver.coerce(version)) !== null && _e !== void 0 ? _e : version;
|
||||||
if (constants_1.DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(extractedDistribution || distributionName)) {
|
|
||||||
const coerceVersion = (_c = semver.coerce(version)) !== null && _c !== void 0 ? _c : version;
|
|
||||||
version = semver.major(coerceVersion).toString();
|
version = semver.major(coerceVersion).toString();
|
||||||
}
|
}
|
||||||
return {
|
return version.toString();
|
||||||
version: version.toString(),
|
|
||||||
distribution: extractedDistribution
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
exports.getVersionFromFileContent = getVersionFromFileContent;
|
exports.getVersionFromFileContent = getVersionFromFileContent;
|
||||||
// Map SDKMAN distribution identifiers to setup-java distribution names
|
|
||||||
function mapSdkmanDistribution(sdkmanDist) {
|
|
||||||
const distributionMap = {
|
|
||||||
tem: 'temurin',
|
|
||||||
sem: 'semeru',
|
|
||||||
albba: 'dragonwell',
|
|
||||||
zulu: 'zulu',
|
|
||||||
amzn: 'corretto',
|
|
||||||
graal: 'graalvm',
|
|
||||||
graalce: 'graalvm',
|
|
||||||
librca: 'liberica',
|
|
||||||
ms: 'microsoft',
|
|
||||||
oracle: 'oracle',
|
|
||||||
sapmchn: 'sapmachine',
|
|
||||||
jbr: 'jetbrains',
|
|
||||||
dragonwell: 'dragonwell',
|
|
||||||
kona: 'kona'
|
|
||||||
};
|
|
||||||
const mapped = distributionMap[sdkmanDist.toLowerCase()];
|
|
||||||
if (!mapped) {
|
|
||||||
core.warning(`Unknown SDKMAN distribution identifier '${sdkmanDist}'. Please specify the distribution explicitly.`);
|
|
||||||
}
|
|
||||||
return mapped;
|
|
||||||
}
|
|
||||||
// By convention, action expects version 8 in the format `8.*` instead of `1.8`
|
// By convention, action expects version 8 in the format `8.*` instead of `1.8`
|
||||||
function avoidOldNotation(content) {
|
function avoidOldNotation(content) {
|
||||||
return content.startsWith('1.') ? content.substring(2) : content;
|
return content.startsWith('1.') ? content.substring(2) : content;
|
||||||
|
|||||||
+3
-88
@@ -16,7 +16,6 @@
|
|||||||
- [Installing custom Java package type](#Installing-custom-Java-package-type)
|
- [Installing custom Java package type](#Installing-custom-Java-package-type)
|
||||||
- [JavaFX Maven project](#JavaFX-Maven-project)
|
- [JavaFX Maven project](#JavaFX-Maven-project)
|
||||||
- [Installing custom Java architecture](#Installing-custom-Java-architecture)
|
- [Installing custom Java architecture](#Installing-custom-Java-architecture)
|
||||||
- [Installing JDK without setting as default](#Installing-JDK-without-setting-as-default)
|
|
||||||
- [Installing custom Java distribution from local file](#Installing-Java-from-local-file)
|
- [Installing custom Java distribution from local file](#Installing-Java-from-local-file)
|
||||||
- [Testing against different Java distributions](#Testing-against-different-Java-distributions)
|
- [Testing against different Java distributions](#Testing-against-different-Java-distributions)
|
||||||
- [Testing against different platforms](#Testing-against-different-platforms)
|
- [Testing against different platforms](#Testing-against-different-platforms)
|
||||||
@@ -298,34 +297,6 @@ steps:
|
|||||||
- run: java --version
|
- run: java --version
|
||||||
```
|
```
|
||||||
|
|
||||||
## Installing JDK without setting as default
|
|
||||||
|
|
||||||
When installing multiple JDKs, the last one installed becomes the default (`JAVA_HOME`, `PATH`). Use the `set-default` option to install a JDK without overriding the default. The installed JDK is still discoverable via the `JAVA_HOME_<major>_<arch>` environment variable (e.g. `JAVA_HOME_21_X64`).
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- uses: actions/setup-java@v5
|
|
||||||
with:
|
|
||||||
distribution: 'temurin'
|
|
||||||
java-version: '17'
|
|
||||||
- uses: actions/setup-java@v5
|
|
||||||
id: setup-java-21
|
|
||||||
with:
|
|
||||||
distribution: 'temurin'
|
|
||||||
java-version: '21'
|
|
||||||
set-default: false
|
|
||||||
- run: |
|
|
||||||
echo "Default java:"
|
|
||||||
java -version
|
|
||||||
echo "Java 21 home: $JAVA_HOME_21_X64"
|
|
||||||
echo "Java 21 path from output: ${{ steps.setup-java-21.outputs.path }}"
|
|
||||||
```
|
|
||||||
|
|
||||||
In this example, `JAVA_HOME` and `java` on `PATH` point to Java 17, while Java 21 is available via `JAVA_HOME_21_X64` or the step output `path`.
|
|
||||||
|
|
||||||
> **Note:** When a single step installs multiple JDKs via a multiline `java-version`, the `set-default` value applies to all of them. With `set-default: false`, none of those JDKs become the default; each remains discoverable through its `JAVA_HOME_<major>_<arch>` variable. Regardless of `set-default`, installed JDKs are still registered in the Maven toolchains file, so they can be selected via Maven toolchains.
|
|
||||||
|
|
||||||
## Installing Java from local file
|
## Installing Java from local file
|
||||||
If your use-case requires a custom distribution or a version that is not provided by setup-java, you can download it manually and setup-java will take care of the installation and caching on the VM:
|
If your use-case requires a custom distribution or a version that is not provided by setup-java, you can download it manually and setup-java will take care of the installation and caching on the VM:
|
||||||
|
|
||||||
@@ -516,8 +487,6 @@ The two `settings.xml` files created from the above example look like the follow
|
|||||||
|
|
||||||
***NOTE***: The `settings.xml` file is created in the Actions `$HOME/.m2` directory. If you have an existing `settings.xml` file at that location, it will be overwritten. See [below](#apache-maven-with-a-settings-path) for using the `settings-path` to change your `settings.xml` file location.
|
***NOTE***: The `settings.xml` file is created in the Actions `$HOME/.m2` directory. If you have an existing `settings.xml` file at that location, it will be overwritten. See [below](#apache-maven-with-a-settings-path) for using the `settings-path` to change your `settings.xml` file location.
|
||||||
|
|
||||||
***NOTE***: The generated `settings.xml` sets `<interactiveMode>false</interactiveMode>` so that Maven never blocks a CI run waiting on an interactive prompt. This is applied automatically whenever the action generates `settings.xml`.
|
|
||||||
|
|
||||||
If you don't want to overwrite the `settings.xml` file, you can set `overwrite-settings: false`
|
If you don't want to overwrite the `settings.xml` file, you can set `overwrite-settings: false`
|
||||||
|
|
||||||
### Extra setup for pom.xml:
|
### Extra setup for pom.xml:
|
||||||
@@ -603,44 +572,6 @@ jobs:
|
|||||||
- This setting only affects Maven. It has no effect on Gradle, sbt, or other build tools.
|
- This setting only affects Maven. It has no effect on Gradle, sbt, or other build tools.
|
||||||
- `-ntp` only controls transfer/progress output; it does not change whether Maven runs in batch mode. Use `-B`/`--batch-mode` (or `<interactiveMode>false</interactiveMode>` in `settings.xml`) if you also want non-interactive runs.
|
- `-ntp` only controls transfer/progress output; it does not change whether Maven runs in batch mode. Use `-B`/`--batch-mode` (or `<interactiveMode>false</interactiveMode>` in `settings.xml`) if you also want non-interactive runs.
|
||||||
|
|
||||||
## Java problem matcher (compiler annotations)
|
|
||||||
|
|
||||||
`setup-java` registers a [problem matcher](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md) for Java after installing the JDK. It scans the log output of subsequent steps and turns `javac` diagnostics into GitHub [annotations](https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-a-warning-message) that appear in the run summary and inline on the affected files. It matches two kinds of lines:
|
|
||||||
|
|
||||||
- Compiler errors and warnings, e.g. `App.java:12: error: cannot find symbol` (owner `javac`).
|
|
||||||
- Uncaught-exception header lines, e.g. `Exception in thread "main" ...`; because these lines have no file or line captures, they appear as log/run-level annotations rather than inline file annotations (owner `java`).
|
|
||||||
|
|
||||||
This is enabled by default and requires no configuration.
|
|
||||||
|
|
||||||
### Disabling the problem matcher
|
|
||||||
|
|
||||||
There is no action input to turn the matcher off, but you can disable it for the rest of the job with the built-in [`remove-matcher`](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md#remove-a-problem-matcher) workflow command. Pass the matcher **owner** (not a file name); the Java matcher defines two owners, `javac` and `java`, so remove both to fully suppress it:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- uses: actions/setup-java@v5
|
|
||||||
with:
|
|
||||||
distribution: '<distribution>'
|
|
||||||
java-version: '21'
|
|
||||||
|
|
||||||
- name: Disable the Java problem matcher
|
|
||||||
run: |
|
|
||||||
echo "::remove-matcher owner=javac::"
|
|
||||||
echo "::remove-matcher owner=java::"
|
|
||||||
|
|
||||||
- name: Build with Maven
|
|
||||||
run: mvn -B package --file pom.xml
|
|
||||||
```
|
|
||||||
|
|
||||||
***NOTES***:
|
|
||||||
- `remove-matcher` only stops annotations from being created; the underlying compiler output is unchanged, so a failing `javac`/build still fails the step.
|
|
||||||
- The command is scoped to the job, so add the step right after `setup-java` (and before your build) in every job where you want the matcher disabled.
|
|
||||||
|
|
||||||
## Publishing using Gradle
|
## Publishing using Gradle
|
||||||
```yaml
|
```yaml
|
||||||
jobs:
|
jobs:
|
||||||
@@ -781,34 +712,18 @@ steps:
|
|||||||
Supported files are `.java-version`, `.tool-versions` and `.sdkmanrc`.
|
Supported files are `.java-version`, `.tool-versions` and `.sdkmanrc`.
|
||||||
* In `.java-version` file, only the version should be specified (e.g., 17.0.7). The `.java-version` file recognizes all variants of the version description according to [jenv](https://github.com/jenv/jenv).
|
* In `.java-version` file, only the version should be specified (e.g., 17.0.7). The `.java-version` file recognizes all variants of the version description according to [jenv](https://github.com/jenv/jenv).
|
||||||
* In `.tool-versions` file, java version should be preceded by the java keyword (e.g., java 17.0.7). The `.tool-versions` file supports version specifications in accordance with [asdf](https://github.com/asdf-vm/asdf) standards, adhering to Semantic Versioning ([semver](https://semver.org/)).
|
* In `.tool-versions` file, java version should be preceded by the java keyword (e.g., java 17.0.7). The `.tool-versions` file supports version specifications in accordance with [asdf](https://github.com/asdf-vm/asdf) standards, adhering to Semantic Versioning ([semver](https://semver.org/)).
|
||||||
* In `.sdkmanrc` file, java version should be preceded by the `java=` prefix (e.g., `java=17.0.7-tem`). When a recognized SDKMAN distribution suffix is present, setup-java can infer the `distribution` input automatically. Unrecognized suffixes require setting `distribution` explicitly. The `.sdkmanrc` file supports version specifications in accordance with [file format](https://sdkman.io/usage#env-command), see [Sdkman! documentation](https://sdkman.io/jdks) for more information.
|
* In `.sdkmanrc` file, java version should be preceded by the `java=` prefix (e.g., java=17.0.7-tem) and include the distribution. The `.sdkmanrc` file supports version specifications in accordance with [file format](https://sdkman.io/usage#env-command), see [Sdkman! documentation](https://sdkman.io/jdks) for more information.
|
||||||
|
|
||||||
Supported SDKMAN suffix mappings:
|
|
||||||
|
|
||||||
| SDKMAN suffix | setup-java distribution |
|
|
||||||
| ------------- | ----------------------- |
|
|
||||||
| `tem` | `temurin` |
|
|
||||||
| `sem` | `semeru` |
|
|
||||||
| `albba`, `dragonwell` | `dragonwell` |
|
|
||||||
| `zulu` | `zulu` |
|
|
||||||
| `amzn` | `corretto` |
|
|
||||||
| `graal`, `graalce` | `graalvm` |
|
|
||||||
| `librca` | `liberica` |
|
|
||||||
| `ms` | `microsoft` |
|
|
||||||
| `oracle` | `oracle` |
|
|
||||||
| `sapmchn` | `sapmachine` |
|
|
||||||
| `jbr` | `jetbrains` |
|
|
||||||
| `kona` | `kona` |
|
|
||||||
|
|
||||||
|
|
||||||
If both `java-version` and `java-version-file` **inputs** are provided, the `java-version` input will be used.
|
If both `java-version` and `java-version-file` **inputs** are provided, the `java-version` input will be used.
|
||||||
|
|
||||||
**Example step using `Sdkman!`** (distribution inferred from `.sdkmanrc`):
|
**Example step using `Sdkman!`**:
|
||||||
```yml
|
```yml
|
||||||
- name: Setup java
|
- name: Setup java
|
||||||
uses: actions/setup-java@v5
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
java-version-file: '.sdkmanrc'
|
java-version-file: '.sdkmanrc'
|
||||||
|
distribution: 'temurin'
|
||||||
```
|
```
|
||||||
|
|
||||||
**Example `.sdkmanrc`**:
|
**Example `.sdkmanrc`**:
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ export const INPUT_JAVA_PACKAGE = 'java-package';
|
|||||||
export const INPUT_DISTRIBUTION = 'distribution';
|
export const INPUT_DISTRIBUTION = 'distribution';
|
||||||
export const INPUT_JDK_FILE = 'jdkFile';
|
export const INPUT_JDK_FILE = 'jdkFile';
|
||||||
export const INPUT_CHECK_LATEST = 'check-latest';
|
export const INPUT_CHECK_LATEST = 'check-latest';
|
||||||
export const INPUT_SET_DEFAULT = 'set-default';
|
|
||||||
export const INPUT_VERIFY_SIGNATURE = 'verify-signature';
|
export const INPUT_VERIFY_SIGNATURE = 'verify-signature';
|
||||||
export const INPUT_VERIFY_SIGNATURE_PUBLIC_KEY = 'verify-signature-public-key';
|
export const INPUT_VERIFY_SIGNATURE_PUBLIC_KEY = 'verify-signature-public-key';
|
||||||
export const INPUT_SERVER_ID = 'server-id';
|
export const INPUT_SERVER_ID = 'server-id';
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ export abstract class JavaBase {
|
|||||||
protected packageType: string;
|
protected packageType: string;
|
||||||
protected stable: boolean;
|
protected stable: boolean;
|
||||||
protected checkLatest: boolean;
|
protected checkLatest: boolean;
|
||||||
protected setDefault: boolean;
|
|
||||||
protected verifySignature: boolean;
|
protected verifySignature: boolean;
|
||||||
protected verifySignaturePublicKey: string | undefined;
|
protected verifySignaturePublicKey: string | undefined;
|
||||||
|
|
||||||
@@ -39,10 +38,6 @@ export abstract class JavaBase {
|
|||||||
this.architecture = installerOptions.architecture || os.arch();
|
this.architecture = installerOptions.architecture || os.arch();
|
||||||
this.packageType = installerOptions.packageType;
|
this.packageType = installerOptions.packageType;
|
||||||
this.checkLatest = installerOptions.checkLatest;
|
this.checkLatest = installerOptions.checkLatest;
|
||||||
this.setDefault =
|
|
||||||
installerOptions.setDefault !== undefined
|
|
||||||
? installerOptions.setDefault
|
|
||||||
: true;
|
|
||||||
this.verifySignature = installerOptions.verifySignature ?? false;
|
this.verifySignature = installerOptions.verifySignature ?? false;
|
||||||
this.verifySignaturePublicKey = installerOptions.verifySignaturePublicKey;
|
this.verifySignaturePublicKey = installerOptions.verifySignaturePublicKey;
|
||||||
}
|
}
|
||||||
@@ -184,15 +179,8 @@ export abstract class JavaBase {
|
|||||||
foundJava.path = macOSPostfixPath;
|
foundJava.path = macOSPostfixPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.setDefault) {
|
core.info(`Setting Java ${foundJava.version} as the default`);
|
||||||
core.info(`Setting Java ${foundJava.version} as the default`);
|
this.setJavaDefault(foundJava.version, foundJava.path);
|
||||||
this.setJavaDefault(foundJava.version, foundJava.path);
|
|
||||||
} else {
|
|
||||||
core.info(
|
|
||||||
`Installing Java ${foundJava.version} (not setting as default)`
|
|
||||||
);
|
|
||||||
this.setJavaEnvironment(foundJava.version, foundJava.path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return foundJava;
|
return foundJava;
|
||||||
}
|
}
|
||||||
@@ -324,13 +312,9 @@ export abstract class JavaBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected setJavaDefault(version: string, toolPath: string) {
|
protected setJavaDefault(version: string, toolPath: string) {
|
||||||
|
const majorVersion = version.split('.')[0];
|
||||||
core.exportVariable('JAVA_HOME', toolPath);
|
core.exportVariable('JAVA_HOME', toolPath);
|
||||||
core.addPath(path.join(toolPath, 'bin'));
|
core.addPath(path.join(toolPath, 'bin'));
|
||||||
this.setJavaEnvironment(version, toolPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected setJavaEnvironment(version: string, toolPath: string) {
|
|
||||||
const majorVersion = version.split('.')[0];
|
|
||||||
core.setOutput('distribution', this.distribution);
|
core.setOutput('distribution', this.distribution);
|
||||||
core.setOutput('path', toolPath);
|
core.setOutput('path', toolPath);
|
||||||
core.setOutput('version', version);
|
core.setOutput('version', version);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ export interface JavaInstallerOptions {
|
|||||||
architecture: string;
|
architecture: string;
|
||||||
packageType: string;
|
packageType: string;
|
||||||
checkLatest: boolean;
|
checkLatest: boolean;
|
||||||
setDefault?: boolean;
|
|
||||||
verifySignature?: boolean;
|
verifySignature?: boolean;
|
||||||
verifySignaturePublicKey?: string;
|
verifySignaturePublicKey?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,15 +69,9 @@ export class LocalDistribution extends JavaBase {
|
|||||||
foundJava.path = macOSPostfixPath;
|
foundJava.path = macOSPostfixPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.setDefault) {
|
core.info(`Setting Java ${foundJava.version} as default`);
|
||||||
core.info(`Setting Java ${foundJava.version} as the default`);
|
|
||||||
this.setJavaDefault(foundJava.version, foundJava.path);
|
this.setJavaDefault(foundJava.version, foundJava.path);
|
||||||
} else {
|
|
||||||
core.info(
|
|
||||||
`Installing Java ${foundJava.version} (not setting as default)`
|
|
||||||
);
|
|
||||||
this.setJavaEnvironment(foundJava.version, foundJava.path);
|
|
||||||
}
|
|
||||||
return foundJava;
|
return foundJava;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+21
-53
@@ -17,7 +17,9 @@ import {configureMavenArgs} from './maven-args';
|
|||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION);
|
const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION);
|
||||||
let distributionName = core.getInput(constants.INPUT_DISTRIBUTION);
|
const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, {
|
||||||
|
required: true
|
||||||
|
});
|
||||||
const versionFile = core.getInput(constants.INPUT_JAVA_VERSION_FILE);
|
const versionFile = core.getInput(constants.INPUT_JAVA_VERSION_FILE);
|
||||||
const architecture = core.getInput(constants.INPUT_ARCHITECTURE);
|
const architecture = core.getInput(constants.INPUT_ARCHITECTURE);
|
||||||
const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
|
const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
|
||||||
@@ -27,7 +29,6 @@ async function run() {
|
|||||||
constants.INPUT_CACHE_DEPENDENCY_PATH
|
constants.INPUT_CACHE_DEPENDENCY_PATH
|
||||||
);
|
);
|
||||||
const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false);
|
const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false);
|
||||||
const setDefault = getBooleanInput(constants.INPUT_SET_DEFAULT, true);
|
|
||||||
const verifySignature = getBooleanInput(
|
const verifySignature = getBooleanInput(
|
||||||
constants.INPUT_VERIFY_SIGNATURE,
|
constants.INPUT_VERIFY_SIGNATURE,
|
||||||
false
|
false
|
||||||
@@ -46,71 +47,41 @@ async function run() {
|
|||||||
throw new Error('java-version or java-version-file input expected');
|
throw new Error('java-version or java-version-file input expected');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const installerInputsOptions: installerInputsOptions = {
|
||||||
|
architecture,
|
||||||
|
packageType,
|
||||||
|
checkLatest,
|
||||||
|
verifySignature,
|
||||||
|
verifySignaturePublicKey,
|
||||||
|
distributionName,
|
||||||
|
jdkFile,
|
||||||
|
toolchainIds
|
||||||
|
};
|
||||||
|
|
||||||
if (!versions.length) {
|
if (!versions.length) {
|
||||||
core.debug(
|
core.debug(
|
||||||
'java-version input is empty, looking for java-version-file input'
|
'java-version input is empty, looking for java-version-file input'
|
||||||
);
|
);
|
||||||
const content = fs.readFileSync(versionFile).toString().trim();
|
const content = fs.readFileSync(versionFile).toString().trim();
|
||||||
|
|
||||||
const versionInfo = getVersionFromFileContent(
|
const version = getVersionFromFileContent(
|
||||||
content,
|
content,
|
||||||
distributionName,
|
distributionName,
|
||||||
versionFile
|
versionFile
|
||||||
);
|
);
|
||||||
core.debug(`Parsed version from file '${versionInfo?.version}'`);
|
core.debug(`Parsed version from file '${version}'`);
|
||||||
|
|
||||||
if (!versionInfo) {
|
if (!version) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`No supported version was found in file ${versionFile}`
|
`No supported version was found in file ${versionFile}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use distribution from file if available, otherwise use the input
|
await installVersion(version, installerInputsOptions);
|
||||||
if (versionInfo.distribution) {
|
}
|
||||||
core.info(
|
|
||||||
`Using distribution '${versionInfo.distribution}' from ${versionFile}`
|
|
||||||
);
|
|
||||||
distributionName = versionInfo.distribution;
|
|
||||||
} else if (!distributionName) {
|
|
||||||
throw new Error(
|
|
||||||
'distribution input is required when not specified in the version file'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const installerInputsOptions: installerInputsOptions = {
|
for (const [index, version] of versions.entries()) {
|
||||||
architecture,
|
await installVersion(version, installerInputsOptions, index);
|
||||||
packageType,
|
|
||||||
checkLatest,
|
|
||||||
setDefault,
|
|
||||||
verifySignature,
|
|
||||||
verifySignaturePublicKey,
|
|
||||||
distributionName,
|
|
||||||
jdkFile,
|
|
||||||
toolchainIds
|
|
||||||
};
|
|
||||||
|
|
||||||
await installVersion(versionInfo.version, installerInputsOptions);
|
|
||||||
} else {
|
|
||||||
// When using java-version input, distribution is still required
|
|
||||||
if (!distributionName) {
|
|
||||||
throw new Error('distribution input is required');
|
|
||||||
}
|
|
||||||
|
|
||||||
const installerInputsOptions: installerInputsOptions = {
|
|
||||||
architecture,
|
|
||||||
packageType,
|
|
||||||
checkLatest,
|
|
||||||
setDefault,
|
|
||||||
verifySignature,
|
|
||||||
verifySignaturePublicKey,
|
|
||||||
distributionName,
|
|
||||||
jdkFile,
|
|
||||||
toolchainIds
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const [index, version] of versions.entries()) {
|
|
||||||
await installVersion(version, installerInputsOptions, index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
const matchersPath = path.join(__dirname, '..', '..', '.github');
|
const matchersPath = path.join(__dirname, '..', '..', '.github');
|
||||||
@@ -139,7 +110,6 @@ async function installVersion(
|
|||||||
architecture,
|
architecture,
|
||||||
packageType,
|
packageType,
|
||||||
checkLatest,
|
checkLatest,
|
||||||
setDefault,
|
|
||||||
verifySignature,
|
verifySignature,
|
||||||
verifySignaturePublicKey,
|
verifySignaturePublicKey,
|
||||||
toolchainIds
|
toolchainIds
|
||||||
@@ -149,7 +119,6 @@ async function installVersion(
|
|||||||
architecture,
|
architecture,
|
||||||
packageType,
|
packageType,
|
||||||
checkLatest,
|
checkLatest,
|
||||||
setDefault,
|
|
||||||
verifySignature,
|
verifySignature,
|
||||||
verifySignaturePublicKey,
|
verifySignaturePublicKey,
|
||||||
version
|
version
|
||||||
@@ -186,7 +155,6 @@ interface installerInputsOptions {
|
|||||||
architecture: string;
|
architecture: string;
|
||||||
packageType: string;
|
packageType: string;
|
||||||
checkLatest: boolean;
|
checkLatest: boolean;
|
||||||
setDefault: boolean;
|
|
||||||
verifySignature: boolean;
|
verifySignature: boolean;
|
||||||
verifySignaturePublicKey: string | undefined;
|
verifySignaturePublicKey: string | undefined;
|
||||||
distributionName: string;
|
distributionName: string;
|
||||||
|
|||||||
+6
-61
@@ -127,18 +127,12 @@ export function isCacheFeatureAvailable(): boolean {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface VersionInfo {
|
|
||||||
version: string;
|
|
||||||
distribution?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getVersionFromFileContent(
|
export function getVersionFromFileContent(
|
||||||
content: string,
|
content: string,
|
||||||
distributionName: string,
|
distributionName: string,
|
||||||
versionFile: string
|
versionFile: string
|
||||||
): VersionInfo | null {
|
): string | null {
|
||||||
let javaVersionRegExp: RegExp;
|
let javaVersionRegExp: RegExp;
|
||||||
let extractedDistribution: string | undefined;
|
|
||||||
|
|
||||||
function getFileName(versionFile: string) {
|
function getFileName(versionFile: string) {
|
||||||
return path.basename(versionFile);
|
return path.basename(versionFile);
|
||||||
@@ -149,27 +143,15 @@ export function getVersionFromFileContent(
|
|||||||
javaVersionRegExp =
|
javaVersionRegExp =
|
||||||
/^java\s+(?:\S*-)?(?<version>\d+(?:\.\d+)*([+_.-](?:openj9[-._]?\d[\w.-]*|java\d+|jre[-_\w]*|OpenJDK\d+[\w_.-]*|[a-z0-9]+))*)/im;
|
/^java\s+(?:\S*-)?(?<version>\d+(?:\.\d+)*([+_.-](?:openj9[-._]?\d[\w.-]*|java\d+|jre[-_\w]*|OpenJDK\d+[\w_.-]*|[a-z0-9]+))*)/im;
|
||||||
} else if (versionFileName == '.sdkmanrc') {
|
} else if (versionFileName == '.sdkmanrc') {
|
||||||
// Match both version and optional distribution identifier
|
javaVersionRegExp = /^java\s*=\s*(?<version>[^-]+)/m;
|
||||||
javaVersionRegExp =
|
|
||||||
/^java\s*=\s*(?<version>[^-\s]+)(?:-(?<distribution>[a-z0-9]+))?/m;
|
|
||||||
} else {
|
} else {
|
||||||
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
javaVersionRegExp = /(?<version>(?<=(^|\s|-))(\d+\S*))(\s|$)/;
|
||||||
}
|
}
|
||||||
|
|
||||||
const match = content.match(javaVersionRegExp);
|
const capturedVersion = content.match(javaVersionRegExp)?.groups?.version
|
||||||
const capturedVersion = match?.groups?.version
|
? (content.match(javaVersionRegExp)?.groups?.version as string)
|
||||||
? (match.groups.version as string)
|
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
// Extract distribution from .sdkmanrc file
|
|
||||||
if (versionFileName == '.sdkmanrc' && match?.groups?.distribution) {
|
|
||||||
const sdkmanDist = match.groups.distribution;
|
|
||||||
extractedDistribution = mapSdkmanDistribution(sdkmanDist);
|
|
||||||
core.debug(
|
|
||||||
`Parsed distribution '${extractedDistribution}' from SDKMAN identifier '${sdkmanDist}'`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
core.debug(
|
core.debug(
|
||||||
`Parsed version '${capturedVersion}' from file '${versionFileName}'`
|
`Parsed version '${capturedVersion}' from file '${versionFileName}'`
|
||||||
);
|
);
|
||||||
@@ -190,49 +172,12 @@ export function getVersionFromFileContent(
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply DISTRIBUTIONS_ONLY_MAJOR_VERSION logic whenever the effective distribution
|
if (DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(distributionName)) {
|
||||||
// (either explicitly provided or extracted from the version file) is in the list.
|
|
||||||
if (
|
|
||||||
DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(
|
|
||||||
extractedDistribution || distributionName
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
const coerceVersion = semver.coerce(version) ?? version;
|
const coerceVersion = semver.coerce(version) ?? version;
|
||||||
version = semver.major(coerceVersion).toString();
|
version = semver.major(coerceVersion).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return version.toString();
|
||||||
version: version.toString(),
|
|
||||||
distribution: extractedDistribution
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Map SDKMAN distribution identifiers to setup-java distribution names
|
|
||||||
function mapSdkmanDistribution(sdkmanDist: string): string | undefined {
|
|
||||||
const distributionMap: Record<string, string> = {
|
|
||||||
tem: 'temurin',
|
|
||||||
sem: 'semeru',
|
|
||||||
albba: 'dragonwell',
|
|
||||||
zulu: 'zulu',
|
|
||||||
amzn: 'corretto',
|
|
||||||
graal: 'graalvm',
|
|
||||||
graalce: 'graalvm',
|
|
||||||
librca: 'liberica',
|
|
||||||
ms: 'microsoft',
|
|
||||||
oracle: 'oracle',
|
|
||||||
sapmchn: 'sapmachine',
|
|
||||||
jbr: 'jetbrains',
|
|
||||||
dragonwell: 'dragonwell',
|
|
||||||
kona: 'kona'
|
|
||||||
};
|
|
||||||
|
|
||||||
const mapped = distributionMap[sdkmanDist.toLowerCase()];
|
|
||||||
if (!mapped) {
|
|
||||||
core.warning(
|
|
||||||
`Unknown SDKMAN distribution identifier '${sdkmanDist}'. Please specify the distribution explicitly.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return mapped;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// By convention, action expects version 8 in the format `8.*` instead of `1.8`
|
// By convention, action expects version 8 in the format `8.*` instead of `1.8`
|
||||||
|
|||||||
Reference in New Issue
Block a user