mirror of
https://github.com/actions/setup-java.git
synced 2025-04-19 17:36:45 +00:00
add support for multiple jdks
This commit is contained in:
parent
8048bbee47
commit
b6bae374b1
10 changed files with 2852 additions and 96 deletions
37
.github/workflows/e2e-versions.yml
vendored
37
.github/workflows/e2e-versions.yml
vendored
|
@ -87,6 +87,43 @@ jobs:
|
||||||
run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
|
run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
setup-java-multiple-jdks:
|
||||||
|
name: ${{ matrix.distribution }} ${{ matrix.version }} - multiple jdks - ${{ matrix.os }}
|
||||||
|
needs: setup-java-major-versions
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
|
distribution: ['temurin', 'zulu', 'liberica']
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: setup-java
|
||||||
|
uses: ./
|
||||||
|
id: setup-java
|
||||||
|
with:
|
||||||
|
distribution: ${{ matrix.distribution }}
|
||||||
|
java-version: |
|
||||||
|
11
|
||||||
|
17
|
||||||
|
- name: Verify Java
|
||||||
|
run: |
|
||||||
|
$versionsArr = "11","17"
|
||||||
|
foreach ($version in $versionsArr)
|
||||||
|
{
|
||||||
|
$envName = "JAVA_HOME_${version}_${env:RUNNER_ARCH}"
|
||||||
|
$JavaVersionPath = [Environment]::GetEnvironmentVariable($envName)
|
||||||
|
if (-not (Test-Path "$JavaVersionPath")) {
|
||||||
|
Write-Host "$envName is not found"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
shell: pwsh
|
||||||
|
- name: Verify Java
|
||||||
|
run: bash __tests__/verify-java.sh "17" "${{ steps.setup-java.outputs.path }}"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
setup-java-ea-versions-zulu:
|
setup-java-ea-versions-zulu:
|
||||||
name: zulu ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }}
|
name: zulu ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }}
|
||||||
needs: setup-java-major-minor-versions
|
needs: setup-java-major-minor-versions
|
||||||
|
|
2
.licenses/npm/@actions/core.dep.yml
generated
2
.licenses/npm/@actions/core.dep.yml
generated
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
name: "@actions/core"
|
name: "@actions/core"
|
||||||
version: 1.2.6
|
version: 1.9.0
|
||||||
type: npm
|
type: npm
|
||||||
summary: Actions core lib
|
summary: Actions core lib
|
||||||
homepage: https://github.com/actions/toolkit/tree/main/packages/core
|
homepage: https://github.com/actions/toolkit/tree/main/packages/core
|
||||||
|
|
18
README.md
18
README.md
|
@ -163,20 +163,10 @@ jobs:
|
||||||
- uses: actions/setup-java@v3
|
- uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
distribution: '<distribution>'
|
distribution: '<distribution>'
|
||||||
java-version: 8
|
java-version: |
|
||||||
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV
|
8
|
||||||
|
11
|
||||||
- uses: actions/setup-java@v3
|
15
|
||||||
with:
|
|
||||||
distribution: '<distribution>'
|
|
||||||
java-version: 11
|
|
||||||
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- uses: actions/setup-java@v3
|
|
||||||
with:
|
|
||||||
distribution: '<distribution>'
|
|
||||||
java-version: 15
|
|
||||||
- run: echo "JAVA_15=$JAVA_HOME" >> $GITHUB_ENV
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Advanced
|
### Advanced
|
||||||
|
|
|
@ -244,6 +244,10 @@ describe('setupJava', () => {
|
||||||
expect(spyGetToolcachePath).toHaveBeenCalled();
|
expect(spyGetToolcachePath).toHaveBeenCalled();
|
||||||
expect(spyCoreAddPath).toHaveBeenCalled();
|
expect(spyCoreAddPath).toHaveBeenCalled();
|
||||||
expect(spyCoreExportVariable).toHaveBeenCalled();
|
expect(spyCoreExportVariable).toHaveBeenCalled();
|
||||||
|
expect(spyCoreExportVariable).toHaveBeenCalledWith(
|
||||||
|
`JAVA_HOME_${input.version}_${input.architecture.toLocaleUpperCase()}`,
|
||||||
|
expected.path
|
||||||
|
);
|
||||||
expect(spyCoreSetOutput).toHaveBeenCalled();
|
expect(spyCoreSetOutput).toHaveBeenCalled();
|
||||||
expect(spyCoreInfo).toHaveBeenCalledWith('Trying to resolve the latest version from remote');
|
expect(spyCoreInfo).toHaveBeenCalledWith('Trying to resolve the latest version from remote');
|
||||||
expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved latest version as ${expected.version}`);
|
expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved latest version as ${expected.version}`);
|
||||||
|
|
1379
dist/cleanup/index.js
vendored
1379
dist/cleanup/index.js
vendored
File diff suppressed because it is too large
Load diff
1419
dist/setup/index.js
vendored
1419
dist/setup/index.js
vendored
File diff suppressed because it is too large
Load diff
38
package-lock.json
generated
38
package-lock.json
generated
|
@ -10,7 +10,7 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^3.0.0",
|
"@actions/cache": "^3.0.0",
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.9.0",
|
||||||
"@actions/exec": "^1.0.4",
|
"@actions/exec": "^1.0.4",
|
||||||
"@actions/glob": "^0.2.0",
|
"@actions/glob": "^0.2.0",
|
||||||
"@actions/http-client": "^1.0.11",
|
"@actions/http-client": "^1.0.11",
|
||||||
|
@ -73,9 +73,20 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/core": {
|
"node_modules/@actions/core": {
|
||||||
"version": "1.2.6",
|
"version": "1.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.0.tgz",
|
||||||
"integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
|
"integrity": "sha512-5pbM693Ih59ZdUhgk+fts+bUWTnIdHV3kwOSr+QIoFHMLg7Gzhwm0cifDY/AG68ekEJAkHnQVpcy4f6GjmzBCA==",
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/http-client": "^2.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@actions/core/node_modules/@actions/http-client": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
||||||
|
"dependencies": {
|
||||||
|
"tunnel": "^0.0.6"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/exec": {
|
"node_modules/@actions/exec": {
|
||||||
"version": "1.0.4",
|
"version": "1.0.4",
|
||||||
|
@ -6712,9 +6723,22 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@actions/core": {
|
"@actions/core": {
|
||||||
"version": "1.2.6",
|
"version": "1.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.0.tgz",
|
||||||
"integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
|
"integrity": "sha512-5pbM693Ih59ZdUhgk+fts+bUWTnIdHV3kwOSr+QIoFHMLg7Gzhwm0cifDY/AG68ekEJAkHnQVpcy4f6GjmzBCA==",
|
||||||
|
"requires": {
|
||||||
|
"@actions/http-client": "^2.0.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/http-client": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
||||||
|
"requires": {
|
||||||
|
"tunnel": "^0.0.6"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"@actions/exec": {
|
"@actions/exec": {
|
||||||
"version": "1.0.4",
|
"version": "1.0.4",
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^3.0.0",
|
"@actions/cache": "^3.0.0",
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.9.0",
|
||||||
"@actions/exec": "^1.0.4",
|
"@actions/exec": "^1.0.4",
|
||||||
"@actions/glob": "^0.2.0",
|
"@actions/glob": "^0.2.0",
|
||||||
"@actions/http-client": "^1.0.11",
|
"@actions/http-client": "^1.0.11",
|
||||||
|
@ -38,11 +38,11 @@
|
||||||
"@types/jest": "^27.0.2",
|
"@types/jest": "^27.0.2",
|
||||||
"@types/node": "^16.11.25",
|
"@types/node": "^16.11.25",
|
||||||
"@types/semver": "^7.3.4",
|
"@types/semver": "^7.3.4",
|
||||||
|
"@vercel/ncc": "^0.33.4",
|
||||||
"jest": "^27.2.5",
|
"jest": "^27.2.5",
|
||||||
"jest-circus": "^27.2.5",
|
"jest-circus": "^27.2.5",
|
||||||
"@vercel/ncc": "^0.33.4",
|
|
||||||
"prettier": "^1.19.1",
|
"prettier": "^1.19.1",
|
||||||
"ts-jest": "^27.0.5",
|
"ts-jest": "^27.0.5",
|
||||||
"typescript": "^4.2.3"
|
"typescript": "^4.2.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,10 +142,12 @@ export abstract class JavaBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected setJavaDefault(version: string, toolPath: string) {
|
protected setJavaDefault(version: string, toolPath: string) {
|
||||||
|
const majorVerssion = 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'));
|
||||||
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);
|
||||||
|
core.exportVariable(`JAVA_HOME_${majorVerssion}_${this.architecture.toUpperCase()}`, toolPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { JavaInstallerOptions } from './distributions/base-models';
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
const version = core.getInput(constants.INPUT_JAVA_VERSION, { required: true });
|
const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION, { required: true });
|
||||||
const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, { required: true });
|
const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, { required: true });
|
||||||
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);
|
||||||
|
@ -17,27 +17,30 @@ async function run() {
|
||||||
const cache = core.getInput(constants.INPUT_CACHE);
|
const cache = core.getInput(constants.INPUT_CACHE);
|
||||||
const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false);
|
const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false);
|
||||||
|
|
||||||
const installerOptions: JavaInstallerOptions = {
|
core.startGroup('Installed distributions');
|
||||||
architecture,
|
for (const version of versions) {
|
||||||
packageType,
|
const installerOptions: JavaInstallerOptions = {
|
||||||
version,
|
architecture,
|
||||||
checkLatest
|
packageType,
|
||||||
};
|
version,
|
||||||
|
checkLatest
|
||||||
|
};
|
||||||
|
|
||||||
const distribution = getJavaDistribution(distributionName, installerOptions, jdkFile);
|
const distribution = getJavaDistribution(distributionName, installerOptions, jdkFile);
|
||||||
if (!distribution) {
|
if (!distribution) {
|
||||||
throw new Error(`No supported distribution was found for input ${distributionName}`);
|
throw new Error(`No supported distribution was found for input ${distributionName}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await distribution.setupJava();
|
||||||
|
|
||||||
|
core.info('');
|
||||||
|
core.info('Java configuration:');
|
||||||
|
core.info(` Distribution: ${distributionName}`);
|
||||||
|
core.info(` Version: ${result.version}`);
|
||||||
|
core.info(` Path: ${result.path}`);
|
||||||
|
core.info('');
|
||||||
}
|
}
|
||||||
|
core.endGroup();
|
||||||
const result = await distribution.setupJava();
|
|
||||||
|
|
||||||
core.info('');
|
|
||||||
core.info('Java configuration:');
|
|
||||||
core.info(` Distribution: ${distributionName}`);
|
|
||||||
core.info(` Version: ${result.version}`);
|
|
||||||
core.info(` Path: ${result.path}`);
|
|
||||||
core.info('');
|
|
||||||
|
|
||||||
const matchersPath = path.join(__dirname, '..', '..', '.github');
|
const matchersPath = path.join(__dirname, '..', '..', '.github');
|
||||||
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
|
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue