Skip to content

Commit 199d480

Browse files
committed
add support for adoptopenjdk binaries
1 parent 4003c04 commit 199d480

File tree

7 files changed

+207
-80
lines changed

7 files changed

+207
-80
lines changed

.github/workflows/workflow.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
runs-on: ${{ matrix.operating-system }}
66
strategy:
77
matrix:
8-
operating-system: [ubuntu-latest, windows-latest]
8+
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
99
steps:
1010
- name: Checkout
1111
uses: actions/checkout@v2
@@ -24,7 +24,7 @@ jobs:
2424
runs-on: ${{ matrix.operating-system }}
2525
strategy:
2626
matrix:
27-
operating-system: [ubuntu-latest, windows-latest]
27+
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
2828
steps:
2929
- name: Checkout
3030
uses: actions/checkout@v2

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ steps:
1919
- uses: actions/checkout@v2
2020
- uses: actions/setup-java@v1
2121
with:
22-
java-version: '9.0.4' # The JDK version to make available on the path.
22+
java-version: '11' # The JDK version to make available on the path.
23+
vendor: zulu # (adoptopenjdk or zulu) - defaults to zulu
2324
java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
2425
architecture: x64 # (x64 or x86) - defaults to x64
2526
- run: java -cp java HelloWorldApp
@@ -30,13 +31,13 @@ Examples of version specifications that the java-version parameter will accept:
3031
3132
e.g. ```6, 7, 8, 9, 10, 11, 12, 13, ...```
3233

33-
- A semver Java version specification
34+
- A semver Java version specification (Zulu only)
3435

3536
e.g. ```8.0.232, 7.0.181, 11.0.4```
3637

3738
e.g. ```8.0.x, >11.0.3, >=13.0.1, <8.0.212```
3839

39-
- An early access (EA) Java version
40+
- An early access (EA) Java version (Zulu only)
4041

4142
e.g. ```14-ea, 15-ea```
4243

@@ -46,7 +47,7 @@ Examples of version specifications that the java-version parameter will accept:
4647

4748
Note that, per semver rules, EA builds will be matched by explicit EA version specifications.
4849

49-
- 1.x syntax
50+
- 1.x syntax (Zulu only)
5051

5152
e.g. ```1.8``` (same as ```8```)
5253

__tests__/installer.test.ts

Lines changed: 62 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ import * as installer from '../src/installer';
1313

1414
let javaFilePath = '';
1515
let javaUrl = '';
16+
let additionalPath = '';
1617
if (process.platform === 'win32') {
1718
javaFilePath = path.join(javaDir, 'java_win.zip');
1819
javaUrl =
1920
'https://download.java.net/java/GA/jdk12/33/GPL/openjdk-12_windows-x64_bin.zip';
2021
} else if (process.platform === 'darwin') {
2122
javaFilePath = path.join(javaDir, 'java_mac.tar.gz');
23+
// macOS tarballs are in bundle format
24+
additionalPath = "/Contents/Home";
2225
javaUrl =
2326
'https://download.java.net/java/GA/jdk12/33/GPL/openjdk-12_osx-x64_bin.tar.gz';
2427
} else {
@@ -51,68 +54,109 @@ describe('installer tests', () => {
5154
}
5255
}, 100000);
5356

54-
it('Installs version of Java from jdkFile if no matching version is installed', async () => {
55-
await installer.getJava('12', 'x64', javaFilePath, 'jdk');
57+
it('Installs version of Java from jdkFile if no matching version is installed AdoptOpenJDK', async () => {
58+
await installer.getJava('12', 'adoptopenjdk', 'x64', javaFilePath, 'jdk');
5659
const JavaDir = path.join(toolDir, 'jdk', '12.0.0', 'x64');
60+
expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
61+
expect(fs.existsSync(path.join(JavaDir, additionalPath, 'bin'))).toBe(true);
62+
}, 100000);
5763

64+
it('Installs version of Java from jdkFile if no matching version is installed Zulu', async () => {
65+
await installer.getJava('12', 'zulu', 'x64', javaFilePath, 'jdk');
66+
const JavaDir = path.join(toolDir, 'jdk', '12.0.0', 'x64');
5867
expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
59-
expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true);
68+
expect(fs.existsSync(path.join(JavaDir, additionalPath, 'bin'))).toBe(true);
6069
}, 100000);
6170

62-
it('Throws if invalid directory to jdk', async () => {
71+
it('Throws if invalid directory to jdk AdoptOpenJDK', async () => {
6372
let thrown = false;
6473
try {
65-
await installer.getJava('1000', 'x64', 'bad path', 'jdk');
74+
await installer.getJava('1000', 'adoptopenjdk', 'x64', 'bad path', 'jdk');
6675
} catch {
6776
thrown = true;
6877
}
6978
expect(thrown).toBe(true);
7079
});
7180

72-
it('Downloads java if no file given', async () => {
73-
await installer.getJava('8.0.102', 'x64', '', 'jdk');
74-
const JavaDir = path.join(toolDir, 'jdk', '8.0.102', 'x64');
81+
it('Throws if invalid directory to jdk Zulu', async () => {
82+
let thrown = false;
83+
try {
84+
await installer.getJava('1000', 'zulu', 'x64', 'bad path', 'jdk');
85+
} catch {
86+
thrown = true;
87+
}
88+
expect(thrown).toBe(true);
89+
});
90+
91+
it('Downloads java if no file given AdoptOpenJDK', async () => {
92+
await installer.getJava('8', 'adoptopenjdk', 'x64', '', 'jdk');
93+
const JavaDir = path.join(toolDir, 'jdk', '8.0.0', 'x64');
94+
95+
expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
96+
expect(fs.existsSync(path.join(JavaDir, additionalPath, 'bin'))).toBe(true);
97+
}, 100000);
7598

99+
it('Downloads java if no file given Zulu', async () => {
100+
await installer.getJava('8.0.102', 'zulu', 'x64', '', 'jdk');
101+
const JavaDir = path.join(toolDir, 'jdk', '8.0.102', 'x64');
76102
expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
77103
expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true);
78104
}, 100000);
79105

80106
it('Downloads java with 1.x syntax', async () => {
81-
await installer.getJava('1.10', 'x64', '', 'jdk');
107+
await installer.getJava('1.10', 'zulu', 'x64', '', 'jdk');
82108
const JavaDir = path.join(toolDir, 'jdk', '10.0.2', 'x64');
83109

84110
expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
85111
expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true);
86112
}, 100000);
87113

88114
it('Downloads java with normal semver syntax', async () => {
89-
await installer.getJava('9.0.x', 'x64', '', 'jdk');
115+
await installer.getJava('9.0.x', 'zulu', 'x64', '', 'jdk');
90116
const JavaDir = path.join(toolDir, 'jdk', '9.0.7', 'x64');
91117

92118
expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
93119
expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true);
94120
}, 100000);
95121

96-
it('Downloads java if package is jre', async () => {
97-
await installer.getJava('8.0.222', 'x64', '', 'jre');
122+
it('Downloads java if package is jre AdoptOpenJDK', async () => {
123+
await installer.getJava('11', 'adoptopenjdk', 'x64', '', 'jre');
124+
const JavaDir = path.join(toolDir, 'jre', '11.0.0', 'x64');
125+
126+
expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
127+
expect(fs.existsSync(path.join(JavaDir, additionalPath, 'bin'))).toBe(true);
128+
}, 100000);
129+
130+
it('Downloads java if package is jre Zulu', async () => {
131+
await installer.getJava('8.0.222', 'zulu', 'x64', '', 'jre');
98132
const JavaDir = path.join(toolDir, 'jre', '8.0.222', 'x64');
99133

100134
expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
101135
expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true);
102136
}, 100000);
103137

104138
it('Downloads java if package is jdk+fx', async () => {
105-
await installer.getJava('8.0.222', 'x64', '', 'jdk+fx');
139+
await installer.getJava('8.0.222', 'zulu', 'x64', '', 'jdk+fx');
106140
const JavaDir = path.join(toolDir, 'jdk+fx', '8.0.222', 'x64');
107141

108142
expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
109143
expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true);
110144
}, 100000);
111145

112-
it('Throws if invalid java package is specified', async () => {
146+
it('Throws if invalid java package is specified AdoptOpenJDK', async () => {
147+
let thrown = false;
148+
try {
149+
await installer.getJava('8', 'adoptopenjdk', 'x64', '', 'bad jdk');
150+
} catch {
151+
thrown = true;
152+
}
153+
expect(thrown).toBe(true);
154+
});
155+
156+
it('Throws if invalid java package is specified Zulu', async () => {
113157
let thrown = false;
114158
try {
115-
await installer.getJava('8.0.222', 'x64', '', 'bad jdk');
159+
await installer.getJava('8.0.222', 'zulu', 'x64', '', 'bad jdk');
116160
} catch {
117161
thrown = true;
118162
}
@@ -122,7 +166,7 @@ describe('installer tests', () => {
122166
it('Throws if invalid directory to jdk', async () => {
123167
let thrown = false;
124168
try {
125-
await installer.getJava('1000', 'x64', 'bad path', 'jdk');
169+
await installer.getJava('1000', 'zulu', 'x64', 'bad path', 'jdk');
126170
} catch {
127171
thrown = true;
128172
}
@@ -136,6 +180,7 @@ describe('installer tests', () => {
136180
// This will throw if it doesn't find it in the cache (because no such version exists)
137181
await installer.getJava(
138182
'250',
183+
'zulu',
139184
'x64',
140185
'path shouldnt matter, found in cache',
141186
'jdk'
@@ -149,7 +194,7 @@ describe('installer tests', () => {
149194
let thrown = false;
150195
try {
151196
// This will throw if it doesn't find it in the cache (because no such version exists)
152-
await installer.getJava('251', 'x64', 'bad path', 'jdk');
197+
await installer.getJava('251', 'zulu', 'x64', 'bad path', 'jdk');
153198
} catch {
154199
thrown = true;
155200
}

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ inputs:
99
Early access versions can be specified in the form of e.g. 14-ea,
1010
14.0.0-ea, or 14.0.0-ea.28'
1111
required: true
12+
vendor:
13+
description: 'The vendor to fetch the binary from (adoptopenjdk, zulu).
14+
Defaults to zulu'
15+
required: false
16+
default: 'jdk'
1217
java-package:
1318
description: 'The package type (jre, jdk, jdk+fx)'
1419
required: false

0 commit comments

Comments
 (0)