Compare commits
8 Commits
rename-v2-
...
v2.1.0
Author | SHA1 | Date | |
---|---|---|---|
d9126d7df2 | |||
53ac717e09 | |||
cbc183b1c1 | |||
0443912ed7 | |||
56b2808da7 | |||
00401c4488 | |||
1e063f2878 | |||
8764a52df1 |
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
@ -5,7 +5,6 @@ on:
|
||||
branches:
|
||||
- main
|
||||
- releases/*
|
||||
- v2-preview
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
|
1
.github/workflows/e2e-local-file.yml
vendored
1
.github/workflows/e2e-local-file.yml
vendored
@ -4,7 +4,6 @@ on:
|
||||
branches:
|
||||
- main
|
||||
- releases/*
|
||||
- v2-preview
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
|
1
.github/workflows/e2e-publishing.yml
vendored
1
.github/workflows/e2e-publishing.yml
vendored
@ -4,7 +4,6 @@ on:
|
||||
branches:
|
||||
- main
|
||||
- releases/*
|
||||
- v2-preview
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
|
6
.github/workflows/e2e-versions.yml
vendored
6
.github/workflows/e2e-versions.yml
vendored
@ -4,13 +4,13 @@ on:
|
||||
branches:
|
||||
- main
|
||||
- releases/*
|
||||
- v2-preview
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
schedule:
|
||||
- cron: '0 */12 * * *'
|
||||
jobs:
|
||||
setup-java-major-versions:
|
||||
name: ${{ matrix.distribution }} ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }}
|
||||
@ -19,7 +19,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
distribution: ['adopt', 'zulu']
|
||||
distribution: ['adopt', 'adopt-openj9', 'zulu'] # internally 'adopt-hotspot' is the same as 'adopt'
|
||||
version: ['8', '11', '15']
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
17
README.md
17
README.md
@ -17,14 +17,14 @@ This action provides the following functionality for GitHub Actions runners:
|
||||
- V2 requires you to specify distribution along with the version. V1 defaults to Zulu OpenJDK, only version input is required. Follow [the migration guide](docs/switching-to-v2.md) to switch from V1 to V2
|
||||
|
||||
## Usage
|
||||
Inputs `java-version` and `distribution` are mandatory. See [Supported distributions](../README.md#Supported-distributions) section for a list of available options.
|
||||
Inputs `java-version` and `distribution` are mandatory. See [Supported distributions](#supported-distributions) section for a list of available options.
|
||||
|
||||
### Basic
|
||||
**Adopt OpenJDK**
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v2-preview
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'adopt' # See 'Supported distributions' for available options
|
||||
java-version: '11'
|
||||
@ -35,7 +35,7 @@ steps:
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v2-preview
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'zulu' # See 'Supported distributions' for available options
|
||||
java-version: '11'
|
||||
@ -53,7 +53,8 @@ Currently, the following distributions are supported:
|
||||
| Keyword | Distribution | Official site | License |
|
||||
|-|-|-|-|
|
||||
| `zulu` | Zulu OpenJDK | [Link](https://www.azul.com/downloads/zulu-community/?package=jdk) | [Link](https://www.azul.com/products/zulu-and-zulu-enterprise/zulu-terms-of-use/) |
|
||||
| `adopt` | Adopt OpenJDK | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html)
|
||||
| `adopt` or `adopt-hotspot` | Adopt OpenJDK Hotspot | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html)
|
||||
| `adopt-openj9` | Adopt OpenJDK OpenJ9 | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html)
|
||||
|
||||
**NOTE:** The different distributors can provide discrepant list of available versions / supported configurations. Please refer to the official documentation to see the list of supported versions.
|
||||
|
||||
@ -68,7 +69,7 @@ For Java distributions that are not cached on Hosted images, `check-latest` alwa
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v2-preview
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: '11'
|
||||
@ -88,7 +89,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Setup java
|
||||
uses: actions/setup-java@v2-preview
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: '<distribution>'
|
||||
java-version: ${{ matrix.java }}
|
||||
@ -110,8 +111,8 @@ jobs:
|
||||
|
||||
## License
|
||||
|
||||
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
||||
The scripts and documentation in this project are released under the [MIT License](LICENSE).
|
||||
|
||||
## Contributions
|
||||
|
||||
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
|
||||
Contributions are welcome! See [Contributor's Guide](CONTRIBUTING.md)
|
||||
|
@ -1,8 +1,6 @@
|
||||
import { HttpClient } from '@actions/http-client';
|
||||
|
||||
import * as semver from 'semver';
|
||||
|
||||
import { AdoptDistribution } from '../../src/distributions/adopt/installer';
|
||||
import { AdoptDistribution, AdoptImplementation } from '../../src/distributions/adopt/installer';
|
||||
import { JavaInstallerOptions } from '../../src/distributions/base-models';
|
||||
|
||||
let manifestData = require('../data/adopt.json') as [];
|
||||
@ -28,26 +26,54 @@ describe('getAvailableVersions', () => {
|
||||
it.each([
|
||||
[
|
||||
{ version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false },
|
||||
'os=mac&architecture=x64&image_type=jdk&release_type=ga&page_size=20&page=0'
|
||||
AdoptImplementation.Hotspot,
|
||||
'os=mac&architecture=x64&image_type=jdk&release_type=ga&jvm_impl=hotspot&page_size=20&page=0'
|
||||
],
|
||||
[
|
||||
{ version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: false },
|
||||
'os=mac&architecture=x86&image_type=jdk&release_type=ga&page_size=20&page=0'
|
||||
AdoptImplementation.Hotspot,
|
||||
'os=mac&architecture=x86&image_type=jdk&release_type=ga&jvm_impl=hotspot&page_size=20&page=0'
|
||||
],
|
||||
[
|
||||
{ version: '11', architecture: 'x64', packageType: 'jre', checkLatest: false },
|
||||
'os=mac&architecture=x64&image_type=jre&release_type=ga&page_size=20&page=0'
|
||||
AdoptImplementation.Hotspot,
|
||||
'os=mac&architecture=x64&image_type=jre&release_type=ga&jvm_impl=hotspot&page_size=20&page=0'
|
||||
],
|
||||
[
|
||||
{ version: '11-ea', architecture: 'x64', packageType: 'jdk', checkLatest: false },
|
||||
'os=mac&architecture=x64&image_type=jdk&release_type=ea&page_size=20&page=0'
|
||||
AdoptImplementation.Hotspot,
|
||||
'os=mac&architecture=x64&image_type=jdk&release_type=ea&jvm_impl=hotspot&page_size=20&page=0'
|
||||
],
|
||||
[
|
||||
{ version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false },
|
||||
AdoptImplementation.OpenJ9,
|
||||
'os=mac&architecture=x64&image_type=jdk&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
|
||||
],
|
||||
[
|
||||
{ version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: false },
|
||||
AdoptImplementation.OpenJ9,
|
||||
'os=mac&architecture=x86&image_type=jdk&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
|
||||
],
|
||||
[
|
||||
{ version: '11', architecture: 'x64', packageType: 'jre', checkLatest: false },
|
||||
AdoptImplementation.OpenJ9,
|
||||
'os=mac&architecture=x64&image_type=jre&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
|
||||
],
|
||||
[
|
||||
{ version: '11-ea', architecture: 'x64', packageType: 'jdk', checkLatest: false },
|
||||
AdoptImplementation.OpenJ9,
|
||||
'os=mac&architecture=x64&image_type=jdk&release_type=ea&jvm_impl=openj9&page_size=20&page=0'
|
||||
]
|
||||
])(
|
||||
'build correct url for %s',
|
||||
async (installerOptions: JavaInstallerOptions, expectedParameters) => {
|
||||
const distribution = new AdoptDistribution(installerOptions);
|
||||
async (
|
||||
installerOptions: JavaInstallerOptions,
|
||||
impl: AdoptImplementation,
|
||||
expectedParameters
|
||||
) => {
|
||||
const distribution = new AdoptDistribution(installerOptions, impl);
|
||||
const baseUrl = 'https://api.adoptopenjdk.net/v3/assets/version/%5B1.0,100.0%5D';
|
||||
const expectedUrl = `${baseUrl}?project=jdk&vendor=adoptopenjdk&heap_size=normal&jvm_impl=hotspot&sort_method=DEFAULT&sort_order=DESC&${expectedParameters}`;
|
||||
const expectedUrl = `${baseUrl}?project=jdk&vendor=adoptopenjdk&heap_size=normal&sort_method=DEFAULT&sort_order=DESC&${expectedParameters}`;
|
||||
distribution['getPlatformOption'] = () => 'mac';
|
||||
|
||||
await distribution['getAvailableVersions']();
|
||||
@ -76,16 +102,32 @@ describe('getAvailableVersions', () => {
|
||||
result: []
|
||||
});
|
||||
|
||||
const distribution = new AdoptDistribution({
|
||||
version: '11',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
const distribution = new AdoptDistribution(
|
||||
{ version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false },
|
||||
AdoptImplementation.Hotspot
|
||||
);
|
||||
const availableVersions = await distribution['getAvailableVersions']();
|
||||
expect(availableVersions).not.toBeNull();
|
||||
expect(availableVersions.length).toBe(manifestData.length * 2);
|
||||
});
|
||||
|
||||
it.each([
|
||||
[AdoptImplementation.Hotspot, 'jdk', 'Java_Adopt_jdk'],
|
||||
[AdoptImplementation.Hotspot, 'jre', 'Java_Adopt_jre'],
|
||||
[AdoptImplementation.OpenJ9, 'jdk', 'Java_Adopt-OpenJ9_jdk'],
|
||||
[AdoptImplementation.OpenJ9, 'jre', 'Java_Adopt-OpenJ9_jre']
|
||||
])(
|
||||
'find right toolchain folder',
|
||||
(impl: AdoptImplementation, packageType: string, expected: string) => {
|
||||
const distribution = new AdoptDistribution(
|
||||
{ version: '11', architecture: 'x64', packageType: packageType, checkLatest: false },
|
||||
impl
|
||||
);
|
||||
|
||||
// @ts-ignore - because it is protected
|
||||
expect(distribution.toolcacheFolderName).toBe(expected);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe('findPackageForDownload', () => {
|
||||
@ -102,24 +144,20 @@ describe('findPackageForDownload', () => {
|
||||
['15.0.1+9', '15.0.1+9'],
|
||||
['15.0.1+9.1', '15.0.1+9.1']
|
||||
])('version is resolved correctly %s -> %s', async (input, expected) => {
|
||||
const distribution = new AdoptDistribution({
|
||||
version: '11',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
const distribution = new AdoptDistribution(
|
||||
{ version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false },
|
||||
AdoptImplementation.Hotspot
|
||||
);
|
||||
distribution['getAvailableVersions'] = async () => manifestData;
|
||||
const resolvedVersion = await distribution['findPackageForDownload'](input);
|
||||
expect(resolvedVersion.version).toBe(expected);
|
||||
});
|
||||
|
||||
it('version is found but binaries list is empty', async () => {
|
||||
const distribution = new AdoptDistribution({
|
||||
version: '11',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
const distribution = new AdoptDistribution(
|
||||
{ version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false },
|
||||
AdoptImplementation.Hotspot
|
||||
);
|
||||
distribution['getAvailableVersions'] = async () => manifestData;
|
||||
await expect(distribution['findPackageForDownload']('9.0.8')).rejects.toThrowError(
|
||||
/Could not find satisfied version for SemVer */
|
||||
@ -127,12 +165,10 @@ describe('findPackageForDownload', () => {
|
||||
});
|
||||
|
||||
it('version is not found', async () => {
|
||||
const distribution = new AdoptDistribution({
|
||||
version: '11',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
const distribution = new AdoptDistribution(
|
||||
{ version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false },
|
||||
AdoptImplementation.Hotspot
|
||||
);
|
||||
distribution['getAvailableVersions'] = async () => manifestData;
|
||||
await expect(distribution['findPackageForDownload']('7.x')).rejects.toThrowError(
|
||||
/Could not find satisfied version for SemVer */
|
||||
@ -140,12 +176,10 @@ describe('findPackageForDownload', () => {
|
||||
});
|
||||
|
||||
it('version list is empty', async () => {
|
||||
const distribution = new AdoptDistribution({
|
||||
version: '11',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
const distribution = new AdoptDistribution(
|
||||
{ version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false },
|
||||
AdoptImplementation.Hotspot
|
||||
);
|
||||
distribution['getAvailableVersions'] = async () => [];
|
||||
await expect(distribution['findPackageForDownload']('11')).rejects.toThrowError(
|
||||
/Could not find satisfied version for SemVer */
|
||||
|
41
dist/setup/index.js
vendored
41
dist/setup/index.js
vendored
@ -1476,23 +1476,28 @@ exports.string = string;
|
||||
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getJavaDistribution = void 0;
|
||||
const installer_1 = __webpack_require__(584);
|
||||
const installer_2 = __webpack_require__(144);
|
||||
const installer_3 = __webpack_require__(393);
|
||||
const installer_1 = __webpack_require__(144);
|
||||
const installer_2 = __webpack_require__(393);
|
||||
const installer_3 = __webpack_require__(584);
|
||||
var JavaDistribution;
|
||||
(function (JavaDistribution) {
|
||||
JavaDistribution["Adopt"] = "adopt";
|
||||
JavaDistribution["AdoptHotspot"] = "adopt-hotspot";
|
||||
JavaDistribution["AdoptOpenJ9"] = "adopt-openj9";
|
||||
JavaDistribution["Zulu"] = "zulu";
|
||||
JavaDistribution["JdkFile"] = "jdkfile";
|
||||
})(JavaDistribution || (JavaDistribution = {}));
|
||||
function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
||||
switch (distributionName) {
|
||||
case JavaDistribution.JdkFile:
|
||||
return new installer_2.LocalDistribution(installerOptions, jdkFile);
|
||||
return new installer_1.LocalDistribution(installerOptions, jdkFile);
|
||||
case JavaDistribution.Adopt:
|
||||
return new installer_1.AdoptDistribution(installerOptions);
|
||||
case JavaDistribution.AdoptHotspot:
|
||||
return new installer_3.AdoptDistribution(installerOptions, installer_3.AdoptImplementation.Hotspot);
|
||||
case JavaDistribution.AdoptOpenJ9:
|
||||
return new installer_3.AdoptDistribution(installerOptions, installer_3.AdoptImplementation.OpenJ9);
|
||||
case JavaDistribution.Zulu:
|
||||
return new installer_3.ZuluDistribution(installerOptions);
|
||||
return new installer_2.ZuluDistribution(installerOptions);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@ -26889,7 +26894,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AdoptDistribution = void 0;
|
||||
exports.AdoptDistribution = exports.AdoptImplementation = void 0;
|
||||
const core = __importStar(__webpack_require__(470));
|
||||
const tc = __importStar(__webpack_require__(139));
|
||||
const fs_1 = __importDefault(__webpack_require__(747));
|
||||
@ -26897,9 +26902,15 @@ const path_1 = __importDefault(__webpack_require__(622));
|
||||
const semver_1 = __importDefault(__webpack_require__(876));
|
||||
const base_installer_1 = __webpack_require__(83);
|
||||
const util_1 = __webpack_require__(322);
|
||||
var AdoptImplementation;
|
||||
(function (AdoptImplementation) {
|
||||
AdoptImplementation["Hotspot"] = "Hotspot";
|
||||
AdoptImplementation["OpenJ9"] = "OpenJ9";
|
||||
})(AdoptImplementation = exports.AdoptImplementation || (exports.AdoptImplementation = {}));
|
||||
class AdoptDistribution extends base_installer_1.JavaBase {
|
||||
constructor(installerOptions) {
|
||||
super('Adopt', installerOptions);
|
||||
constructor(installerOptions, jvmImpl) {
|
||||
super(`Adopt-${jvmImpl}`, installerOptions);
|
||||
this.jvmImpl = jvmImpl;
|
||||
}
|
||||
findPackageForDownload(version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
@ -26944,6 +26955,14 @@ class AdoptDistribution extends base_installer_1.JavaBase {
|
||||
return { version: javaRelease.version, path: javaPath };
|
||||
});
|
||||
}
|
||||
get toolcacheFolderName() {
|
||||
if (this.jvmImpl === AdoptImplementation.Hotspot) {
|
||||
// exclude Hotspot postfix from distribution name because Hosted runners have pre-cached Adopt OpenJDK under "Java_Adopt_jdk"
|
||||
// for more information see: https://github.com/actions/setup-java/pull/155#discussion_r610451063
|
||||
return `Java_Adopt_${this.packageType}`;
|
||||
}
|
||||
return super.toolcacheFolderName;
|
||||
}
|
||||
getAvailableVersions() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const platform = this.getPlatformOption();
|
||||
@ -26956,13 +26975,13 @@ class AdoptDistribution extends base_installer_1.JavaBase {
|
||||
`project=jdk`,
|
||||
'vendor=adoptopenjdk',
|
||||
`heap_size=normal`,
|
||||
`jvm_impl=hotspot`,
|
||||
'sort_method=DEFAULT',
|
||||
'sort_order=DESC',
|
||||
`os=${platform}`,
|
||||
`architecture=${arch}`,
|
||||
`image_type=${imageType}`,
|
||||
`release_type=${releaseType}`
|
||||
`release_type=${releaseType}`,
|
||||
`jvm_impl=${this.jvmImpl.toLowerCase()}`
|
||||
].join('&');
|
||||
// need to iterate through all pages to retrieve the list of all versions
|
||||
// Adopt API doesn't provide way to retrieve the count of pages to iterate so infinity loop
|
||||
|
@ -20,9 +20,9 @@ Inputs `java-version` and `distribution` are mandatory and needs to be provided.
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v2-preview
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
distribution: 'adopt-hotspot' # See 'Supported distributions' for available options @ README.md
|
||||
java-version: '11'
|
||||
- run: java -cp java HelloWorldApp
|
||||
```
|
||||
@ -31,7 +31,7 @@ steps:
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v2-preview
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '11'
|
||||
@ -43,7 +43,7 @@ steps:
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v2-preview
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: '<distribution>'
|
||||
java-version: '11'
|
||||
@ -57,7 +57,7 @@ steps:
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v2-preview
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: '<distribution>'
|
||||
java-version: '11'
|
||||
@ -73,9 +73,9 @@ steps:
|
||||
- run: |
|
||||
download_url="https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.10_9.tar.gz"
|
||||
wget -O $RUNNER_TEMP/java_package.tar.gz $download_url
|
||||
- uses: actions/setup-java@v2-preview
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'jdkFile'
|
||||
distribution: 'jdkfile'
|
||||
jdkFile: ${{ runner.temp }}/java_package.tar.gz
|
||||
java-version: '11.0.0'
|
||||
architecture: x64
|
||||
@ -97,7 +97,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Setup java
|
||||
uses: actions/setup-java@v2-preview
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: ${{ matrix.distribution }}
|
||||
java-version: ${{ matrix.java }}
|
||||
@ -117,7 +117,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Setup java
|
||||
uses: actions/setup-java@v2-preview
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: ${{ matrix.java }}
|
||||
@ -129,13 +129,12 @@ jobs:
|
||||
```yaml
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v2-preview
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: '<distribution>'
|
||||
java-version: '11'
|
||||
@ -149,7 +148,7 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ github.token }} # GITHUB_TOKEN is the default env for the password
|
||||
|
||||
- name: Set up Apache Maven Central
|
||||
uses: actions/setup-java@v2-preview
|
||||
uses: actions/setup-java@v2
|
||||
with: # running setup-java again overwrites the settings.xml
|
||||
distribution: 'adopt'
|
||||
java-version: '11'
|
||||
@ -207,7 +206,7 @@ The two `settings.xml` files created from the above example look like the follow
|
||||
</settings>
|
||||
```
|
||||
|
||||
***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 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.
|
||||
|
||||
If you don't want to overwrite the `settings.xml` file, you can set `overwrite-settings: false`
|
||||
|
||||
@ -234,6 +233,34 @@ If `gpg-private-key` input is provided, the private key will be written to a fil
|
||||
|
||||
See the help docs on [Publishing a Package](https://help.github.com/en/github/managing-packages-with-github-packages/configuring-apache-maven-for-use-with-github-packages#publishing-a-package) for more information on the `pom.xml` file.
|
||||
|
||||
## Apache Maven with a settings path
|
||||
|
||||
When using an Actions self-hosted runner with multiple shared runners the default `$HOME` directory can be shared by a number runners at the same time which could overwrite existing settings file. Setting the `settings-path` variable allows you to choose a unique location for your settings file.
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 11 for Shared Runner
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: '<distribution>'
|
||||
java-version: '11'
|
||||
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
|
||||
settings-path: ${{ github.workspace }} # location for the settings.xml file
|
||||
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
|
||||
- name: Publish to GitHub Packages Apache Maven
|
||||
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
```
|
||||
|
||||
## Publishing using Gradle
|
||||
```yaml
|
||||
jobs:
|
||||
@ -245,7 +272,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v2-preview
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: '<distribution>'
|
||||
java-version: '11'
|
||||
@ -264,35 +291,6 @@ jobs:
|
||||
|
||||
See the help docs on [Publishing a Package with Gradle](https://help.github.com/en/github/managing-packages-with-github-packages/configuring-gradle-for-use-with-github-packages#example-using-gradle-groovy-for-a-single-package-in-a-repository) for more information on the `build.gradle` configuration file.
|
||||
|
||||
## Apache Maven with a settings path
|
||||
|
||||
When using an Actions self-hosted runner with multiple shared runners the default `$HOME` directory can be shared by a number runners at the same time which could overwrite existing settings file. Setting the `settings-path` variable allows you to choose a unique location for your settings file.
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 11 for Shared Runner
|
||||
uses: actions/setup-java@v2-preview
|
||||
with:
|
||||
distribution: '<distribution>'
|
||||
java-version: '11'
|
||||
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
|
||||
settings-path: ${{ github.workspace }} # location for the settings.xml file
|
||||
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
|
||||
- name: Publish to GitHub Packages Apache Maven
|
||||
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
```
|
||||
|
||||
## Hosted Tool Cache
|
||||
GitHub Hosted Runners have a tool cache that comes with some Java versions pre-installed. This tool cache helps speed up runs and tool setup by not requiring any new downloads. There is an environment variable called `RUNNER_TOOL_CACHE` on each runner that describes the location of this tools cache and this is where you can find the pre-installed versions of Java. `setup-java` works by taking a specific version of Java in this tool cache and adding it to PATH if the version, architecture and distribution match.
|
||||
|
||||
|
@ -5,7 +5,7 @@ Use the `zulu` keyword if you would like to continue using the same distribution
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v2-preview
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '11'
|
||||
@ -16,15 +16,15 @@ steps:
|
||||
**General recommendation** — configure CI with the same distribution that is used on your local dev machine.
|
||||
|
||||
## Installing custom Java distribution from local file
|
||||
Since the `distribution` input is required in V2, you should specify it using `jdkFile` to continue installing Java from a local file on the runner
|
||||
Since the `distribution` input is required in V2, you should specify it using `jdkfile` to continue installing Java from a local file on the runner
|
||||
```yaml
|
||||
steps:
|
||||
- run: |
|
||||
download_url="https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.10_9.tar.gz"
|
||||
wget -O $RUNNER_TEMP/java_package.tar.gz $download_url
|
||||
- uses: actions/setup-java@v2-preview
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'jdkFile'
|
||||
distribution: 'jdkfile'
|
||||
jdkFile: ${{ runner.temp }}/java_package.tar.gz
|
||||
java-version: '11.0.0'
|
||||
architecture: x64
|
||||
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -2170,9 +2170,9 @@
|
||||
}
|
||||
},
|
||||
"hosted-git-info": {
|
||||
"version": "2.8.8",
|
||||
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz",
|
||||
"integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==",
|
||||
"version": "2.8.9",
|
||||
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
|
||||
"integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==",
|
||||
"dev": true
|
||||
},
|
||||
"html-encoding-sniffer": {
|
||||
|
@ -7,13 +7,20 @@ import semver from 'semver';
|
||||
|
||||
import { JavaBase } from '../base-installer';
|
||||
import { IAdoptAvailableVersions } from './models';
|
||||
import { JavaInstallerOptions, JavaDownloadRelease, JavaInstallerResults } from '../base-models';
|
||||
import { MACOS_JAVA_CONTENT_POSTFIX } from '../../constants';
|
||||
import { JavaDownloadRelease, JavaInstallerOptions, JavaInstallerResults } from '../base-models';
|
||||
import { extractJdkFile, getDownloadArchiveExtension, isVersionSatisfies } from '../../util';
|
||||
|
||||
export enum AdoptImplementation {
|
||||
Hotspot = 'Hotspot',
|
||||
OpenJ9 = 'OpenJ9'
|
||||
}
|
||||
|
||||
export class AdoptDistribution extends JavaBase {
|
||||
constructor(installerOptions: JavaInstallerOptions) {
|
||||
super('Adopt', installerOptions);
|
||||
constructor(
|
||||
installerOptions: JavaInstallerOptions,
|
||||
private readonly jvmImpl: AdoptImplementation
|
||||
) {
|
||||
super(`Adopt-${jvmImpl}`, installerOptions);
|
||||
}
|
||||
|
||||
protected async findPackageForDownload(version: string): Promise<JavaDownloadRelease> {
|
||||
@ -70,6 +77,15 @@ export class AdoptDistribution extends JavaBase {
|
||||
return { version: javaRelease.version, path: javaPath };
|
||||
}
|
||||
|
||||
protected get toolcacheFolderName(): string {
|
||||
if (this.jvmImpl === AdoptImplementation.Hotspot) {
|
||||
// exclude Hotspot postfix from distribution name because Hosted runners have pre-cached Adopt OpenJDK under "Java_Adopt_jdk"
|
||||
// for more information see: https://github.com/actions/setup-java/pull/155#discussion_r610451063
|
||||
return `Java_Adopt_${this.packageType}`;
|
||||
}
|
||||
return super.toolcacheFolderName;
|
||||
}
|
||||
|
||||
private async getAvailableVersions(): Promise<IAdoptAvailableVersions[]> {
|
||||
const platform = this.getPlatformOption();
|
||||
const arch = this.architecture;
|
||||
@ -83,13 +99,13 @@ export class AdoptDistribution extends JavaBase {
|
||||
`project=jdk`,
|
||||
'vendor=adoptopenjdk',
|
||||
`heap_size=normal`,
|
||||
`jvm_impl=hotspot`,
|
||||
'sort_method=DEFAULT',
|
||||
'sort_order=DESC',
|
||||
`os=${platform}`,
|
||||
`architecture=${arch}`,
|
||||
`image_type=${imageType}`,
|
||||
`release_type=${releaseType}`
|
||||
`release_type=${releaseType}`,
|
||||
`jvm_impl=${this.jvmImpl.toLowerCase()}`
|
||||
].join('&');
|
||||
|
||||
// need to iterate through all pages to retrieve the list of all versions
|
||||
|
@ -1,11 +1,13 @@
|
||||
import { AdoptDistribution } from './adopt/installer';
|
||||
import { JavaBase } from './base-installer';
|
||||
import { JavaInstallerOptions } from './base-models';
|
||||
import { LocalDistribution } from './local/installer';
|
||||
import { ZuluDistribution } from './zulu/installer';
|
||||
import { AdoptDistribution, AdoptImplementation } from './adopt/installer';
|
||||
|
||||
enum JavaDistribution {
|
||||
Adopt = 'adopt',
|
||||
AdoptHotspot = 'adopt-hotspot',
|
||||
AdoptOpenJ9 = 'adopt-openj9',
|
||||
Zulu = 'zulu',
|
||||
JdkFile = 'jdkfile'
|
||||
}
|
||||
@ -19,7 +21,10 @@ export function getJavaDistribution(
|
||||
case JavaDistribution.JdkFile:
|
||||
return new LocalDistribution(installerOptions, jdkFile);
|
||||
case JavaDistribution.Adopt:
|
||||
return new AdoptDistribution(installerOptions);
|
||||
case JavaDistribution.AdoptHotspot:
|
||||
return new AdoptDistribution(installerOptions, AdoptImplementation.Hotspot);
|
||||
case JavaDistribution.AdoptOpenJ9:
|
||||
return new AdoptDistribution(installerOptions, AdoptImplementation.OpenJ9);
|
||||
case JavaDistribution.Zulu:
|
||||
return new ZuluDistribution(installerOptions);
|
||||
default:
|
||||
|
Reference in New Issue
Block a user