From 9e1b2b49a343739689cf751894c770937c167cc2 Mon Sep 17 00:00:00 2001 From: David Kirstein Date: Wed, 11 Dec 2019 21:32:04 +0100 Subject: [PATCH] fix download / tests that use the new Java version cache subdir --- .../java/com/palantir/gradle/graal/DownloadGraalTask.java | 6 +++--- .../java/com/palantir/gradle/graal/GraalVersionUtil.java | 2 +- .../gradle/graal/GradleGraalPluginIntegrationSpec.groovy | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/palantir/gradle/graal/DownloadGraalTask.java b/src/main/java/com/palantir/gradle/graal/DownloadGraalTask.java index 500aadd..cef1851 100644 --- a/src/main/java/com/palantir/gradle/graal/DownloadGraalTask.java +++ b/src/main/java/com/palantir/gradle/graal/DownloadGraalTask.java @@ -55,8 +55,7 @@ public class DownloadGraalTask extends DefaultTask { @TaskAction public final void downloadGraal() throws IOException { - Path cache = getCacheSubdirectory().get(); - Files.createDirectories(cache); + Files.createDirectories(getArchive().get().getAsFile().toPath().getParent()); final String artifactPattern = isGraalRcVersion() ? ARTIFACT_PATTERN_RC_VERSION : ARTIFACT_PATTERN_RELEASE_VERSION; @@ -69,7 +68,8 @@ public class DownloadGraalTask extends DefaultTask { @OutputFile public final Provider getArchive() { return getProject().getLayout() - .file(getCacheSubdirectory().map(dir -> dir.resolve(render(FILENAME_PATTERN)).toFile())); + .file(getCacheSubdirectory() + .map(dir -> dir.resolve(javaVersion.get()).resolve(render(FILENAME_PATTERN)).toFile())); } @Input diff --git a/src/main/java/com/palantir/gradle/graal/GraalVersionUtil.java b/src/main/java/com/palantir/gradle/graal/GraalVersionUtil.java index 273a438..915d15a 100644 --- a/src/main/java/com/palantir/gradle/graal/GraalVersionUtil.java +++ b/src/main/java/com/palantir/gradle/graal/GraalVersionUtil.java @@ -19,7 +19,7 @@ package com.palantir.gradle.graal; public final class GraalVersionUtil { public static boolean isGraalVersionGreatherThan19_3(String graalVersion) { try { - final String[] versionSplit = graalVersion.split("\\."); + final String[] versionSplit = graalVersion.split("\\.", -1); final int majorVersion = Integer.valueOf(versionSplit[0]); final int minorVersion = Integer.valueOf(versionSplit[1]); return majorVersion > 19 || (majorVersion == 19 && minorVersion >= 3); diff --git a/src/test/groovy/com/palantir/gradle/graal/GradleGraalPluginIntegrationSpec.groovy b/src/test/groovy/com/palantir/gradle/graal/GradleGraalPluginIntegrationSpec.groovy index 81cc8c9..3ca3916 100644 --- a/src/test/groovy/com/palantir/gradle/graal/GradleGraalPluginIntegrationSpec.groovy +++ b/src/test/groovy/com/palantir/gradle/graal/GradleGraalPluginIntegrationSpec.groovy @@ -140,7 +140,7 @@ class GradleGraalPluginIntegrationSpec extends IntegrationSpec { server.takeRequest().path =~ "/oracle/graal/releases/download//vm-19.0.0/graalvm-ce-windows-amd64-19.0.0.zip" - file("cacheDir/19.0.0/8/graalvm-ce-java8-19.0.0-amd64.zip").text == '<>' + file("cacheDir/19.0.0/8/graalvm-ce-19.0.0-amd64.zip").text == '<>' } // for Windows the download is a .zip, this is tested below