Skip to content

Commit ad3c25e

Browse files
ansalondfniephaus
authored andcommitted
Support new GraalVM dev artifact names.
They omit the Java version and have `-dev` earlier for consistency with other artifacts. Example: - old: `graalvm-community-java26-linux-amd64-dev.tar.gz` - new: `graalvm-community-dev-linux-amd64.tar.gz`
1 parent cfa19cd commit ad3c25e

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

__tests__/graalvm.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ test('find version/javaVersion', async () => {
7676
}
7777
error = err
7878
}
79-
expect(error.message).toContain('Could not find highest Java version.')
79+
expect(error.message).toContain('Could not find latest GraalVM release:')
8080
})
8181

8282
test('find EA version/javaVersion', async () => {

dist/main.js

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/graalvm.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export async function setUpGraalVMJDKDevBuild(): Promise<string> {
174174
return downloadAndExtractJDK(downloadUrl)
175175
}
176176

177-
export function findHighestJavaVersion(release: c.LatestReleaseResponseData, version: string): string {
177+
export function findHighestJavaVersion(release: c.LatestReleaseResponseData, version: string): string | undefined {
178178
const graalVMIdentifierPattern = determineGraalVMLegacyIdentifier(false, version, '(\\d+)')
179179
const expectedFileNameRegExp = new RegExp(
180180
`^${graalVMIdentifierPattern}${c.GRAALVM_FILE_EXTENSION.replace(/\./g, '\\.')}$`
@@ -192,9 +192,7 @@ export function findHighestJavaVersion(release: c.LatestReleaseResponseData, ver
192192
if (highestJavaVersion > 0) {
193193
return String(highestJavaVersion)
194194
} else {
195-
throw new Error(
196-
'Could not find highest Java version. Please file an issue at: https://github.com/graalvm/setup-graalvm/issues.'
197-
)
195+
return undefined
198196
}
199197
}
200198

@@ -234,8 +232,10 @@ export async function setUpGraalVMRelease(gdsToken: string, version: string, jav
234232
return downloadExtractAndCacheJDK(downloader, toolName, version)
235233
}
236234

237-
function findDownloadUrl(release: c.LatestReleaseResponseData, javaVersion: string): string {
238-
const graalVMIdentifier = determineGraalVMLegacyIdentifier(false, c.VERSION_DEV, javaVersion)
235+
function findDownloadUrl(release: c.LatestReleaseResponseData, javaVersion?: string): string {
236+
const graalVMIdentifier = javaVersion
237+
? determineGraalVMLegacyIdentifier(false, c.VERSION_DEV, javaVersion)
238+
: determineGraalVMIdentifier(false, c.VERSION_DEV)
239239
const expectedFileName = `${graalVMIdentifier}${c.GRAALVM_FILE_EXTENSION}`
240240
for (const asset of release.assets) {
241241
if (asset.name === expectedFileName) {
@@ -247,6 +247,11 @@ function findDownloadUrl(release: c.LatestReleaseResponseData, javaVersion: stri
247247
)
248248
}
249249

250+
function determineGraalVMIdentifier(isEE: boolean, version: string): string {
251+
const infix = isEE ? 'ee' : version === c.VERSION_DEV ? 'community' : 'ce'
252+
return `graalvm-${infix}-${version}-${c.GRAALVM_PLATFORM}-${c.GRAALVM_ARCH}`
253+
}
254+
250255
function determineGraalVMLegacyIdentifier(isEE: boolean, version: string, javaVersion: string): string {
251256
return `${determineLegacyToolName(isEE, version, javaVersion)}-${c.GRAALVM_ARCH}-${version}`
252257
}

0 commit comments

Comments
 (0)