From 7006be56b8df75fedacbe09be3d673ea25044640 Mon Sep 17 00:00:00 2001 From: Choko Date: Sat, 23 Nov 2019 17:59:09 +0900 Subject: [PATCH] Fix update intellij SDKs task to recognize zulu. (#486) * Fix update intellij SDKs task to recognize zulu. * Fix test * Revert typo * Fix test * Actually fix --- common/web/base-node-dev/package.json | 1 + settings.gradle.kts | 2 +- .../gradle.properties | 2 +- .../tasks/UpdateIntelliJSdksTask.java | 36 ++++++++++++++----- ...penjdk-intellij-table-snippet.template.xml | 2 +- .../tasks/UpdateIntelliJSdksTaskTest.java | 30 +++++++++++----- .../existing-and-curio-openjdk.template.xml | 2 +- .../existing-related.xml | 4 +-- .../only-curio-openjdk.template.xml | 2 +- 9 files changed, 57 insertions(+), 24 deletions(-) diff --git a/common/web/base-node-dev/package.json b/common/web/base-node-dev/package.json index 76151db68..b029870da 100644 --- a/common/web/base-node-dev/package.json +++ b/common/web/base-node-dev/package.json @@ -13,3 +13,4 @@ "typescript": "3.7.2" } } + diff --git a/settings.gradle.kts b/settings.gradle.kts index 2f4f25441..b08911819 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -44,7 +44,7 @@ pluginManagement { plugins { id("com.gradle.enterprise").version("3.0") - id("org.curioswitch.gradle-curiostack-plugin").version("0.1.0") + id("org.curioswitch.gradle-curiostack-plugin").version("0.1.1") } configure { diff --git a/tools/gradle-plugins/gradle-curiostack-plugin/gradle.properties b/tools/gradle-plugins/gradle-curiostack-plugin/gradle.properties index a87fc5d73..559c975ae 100644 --- a/tools/gradle-plugins/gradle-curiostack-plugin/gradle.properties +++ b/tools/gradle-plugins/gradle-curiostack-plugin/gradle.properties @@ -22,4 +22,4 @@ # SOFTWARE. # -version = 0.1.0 +version = 0.1.1 diff --git a/tools/gradle-plugins/gradle-curiostack-plugin/src/main/java/org/curioswitch/gradle/plugins/curiostack/tasks/UpdateIntelliJSdksTask.java b/tools/gradle-plugins/gradle-curiostack-plugin/src/main/java/org/curioswitch/gradle/plugins/curiostack/tasks/UpdateIntelliJSdksTask.java index b72e5ead4..341647acf 100644 --- a/tools/gradle-plugins/gradle-curiostack-plugin/src/main/java/org/curioswitch/gradle/plugins/curiostack/tasks/UpdateIntelliJSdksTask.java +++ b/tools/gradle-plugins/gradle-curiostack-plugin/src/main/java/org/curioswitch/gradle/plugins/curiostack/tasks/UpdateIntelliJSdksTask.java @@ -57,11 +57,7 @@ public class UpdateIntelliJSdksTask extends DefaultTask { public static final String NAME = "curioUpdateIntelliJSdks"; - @VisibleForTesting static final String LATEST_INTELLIJ_CONFIG_FOLDER = ".IntelliJIdea2019.2"; - - @VisibleForTesting static final String JAVA_8_VERSION = "1.8.0_222"; - - @VisibleForTesting static final String JDK_8_FOLDER_NAME = "jdk8u222-b10/jdk8u222-b10"; + @VisibleForTesting static final String LATEST_INTELLIJ_CONFIG_FOLDER = ".IntelliJIdea2019.3"; private static final List JAVA_MODULES = ImmutableList.of( @@ -220,22 +216,44 @@ public void exec() throws IOException { .info("Updating IntelliJ folder {}, found folders {}", intelliJFolder, intelliJFolders); String javaVersion = ToolDependencies.getOpenJdkVersion(getProject()); + String majorVersion = + javaVersion.startsWith("zulu") + ? JavaVersion.toVersion(javaVersion.substring("zulu".length())).getMajorVersion() + : JavaVersion.toVersion(javaVersion).getMajorVersion(); + + String java8Version = ToolDependencies.getOpenJdk8Version(getProject()); + final String jdk8FolderSuffix; + switch (new PlatformHelper().getOs()) { + case WINDOWS: + jdk8FolderSuffix = "win_x64"; + break; + case MAC_OSX: + jdk8FolderSuffix = "macosx_x64"; + break; + case LINUX: + jdk8FolderSuffix = "linux_x64"; + break; + default: + throw new IllegalStateException("Unknown OS"); + } + String jdk8FolderName = java8Version + "/" + java8Version + "-" + jdk8FolderSuffix; var jdkTable = Files.createDirectories(intelliJFolder.resolve("config/options")).resolve("jdk.table.xml"); updateConfig( jdkTable, "jdk-" + javaVersion, - JavaVersion.toVersion(javaVersion).getMajorVersion(), + majorVersion, "curiostack/openjdk-intellij-table-snippet.template.xml", - ImmutableMap.of("javaVersion", javaVersion, "javaModules", JAVA_MODULES), + ImmutableMap.of( + "javaVersion", javaVersion, "javaModules", JAVA_MODULES, "majorVersion", majorVersion), getProject()); updateConfig( jdkTable, - JDK_8_FOLDER_NAME, + jdk8FolderName, "1.8", "curiostack/openjdk-8-intellij-table-snippet.template.xml", - ImmutableMap.of("javaVersion", JAVA_8_VERSION, "javaModules", JAVA_8_JARS), + ImmutableMap.of("javaVersion", java8Version, "javaModules", JAVA_8_JARS), getProject()); updateGoSdk(intelliJFolder, getProject()); diff --git a/tools/gradle-plugins/gradle-curiostack-plugin/src/main/resources/curiostack/openjdk-intellij-table-snippet.template.xml b/tools/gradle-plugins/gradle-curiostack-plugin/src/main/resources/curiostack/openjdk-intellij-table-snippet.template.xml index 71c2af339..a2b9a9151 100644 --- a/tools/gradle-plugins/gradle-curiostack-plugin/src/main/resources/curiostack/openjdk-intellij-table-snippet.template.xml +++ b/tools/gradle-plugins/gradle-curiostack-plugin/src/main/resources/curiostack/openjdk-intellij-table-snippet.template.xml @@ -1,5 +1,5 @@ - + diff --git a/tools/gradle-plugins/gradle-curiostack-plugin/src/test/java/org/curioswitch/gradle/plugins/curiostack/tasks/UpdateIntelliJSdksTaskTest.java b/tools/gradle-plugins/gradle-curiostack-plugin/src/test/java/org/curioswitch/gradle/plugins/curiostack/tasks/UpdateIntelliJSdksTaskTest.java index fccb0a519..5acb7c187 100644 --- a/tools/gradle-plugins/gradle-curiostack-plugin/src/test/java/org/curioswitch/gradle/plugins/curiostack/tasks/UpdateIntelliJSdksTaskTest.java +++ b/tools/gradle-plugins/gradle-curiostack-plugin/src/test/java/org/curioswitch/gradle/plugins/curiostack/tasks/UpdateIntelliJSdksTaskTest.java @@ -35,6 +35,7 @@ import java.nio.file.Files; import java.nio.file.Path; import org.curioswitch.gradle.golang.GolangSetupPlugin; +import org.curioswitch.gradle.helpers.platform.PlatformHelper; import org.curioswitch.gradle.plugins.curiostack.CuriostackRootPlugin; import org.curioswitch.gradle.plugins.curiostack.ToolDependencies; import org.curioswitch.gradle.testing.GradleTempDirectories; @@ -64,10 +65,9 @@ void setUserHome() throws Exception { Files.createDirectories(testUserHome.resolve("curiotest")).resolve("foo.txt"), "bar"); var project = ProjectBuilder.builder().withGradleUserHomeDir(testGradleHome.toFile()).build(); - project - .getExtensions() - .getByType(ExtraPropertiesExtension.class) - .set("org.curioswitch.curiostack.tools.openjdk", "11.0.4+11"); + var properties = project.getExtensions().getByType(ExtraPropertiesExtension.class); + properties.set("org.curioswitch.curiostack.tools.openjdk", "zulu13.28.11-ca-jdk13.0.1"); + properties.set("org.curioswitch.curiostack.tools.openjdk8", "zulu8.42.0.21-ca-jdk8.0.232"); project.getPlugins().apply(CuriostackRootPlugin.class); project.getPlugins().apply(GolangSetupPlugin.class); @@ -204,11 +204,25 @@ private String testTemplate(String path) { template, ImmutableMap.builder() .put("gradleHome", testGradleHome.toAbsolutePath().toString().replace('\\', '/')) - .put("jdkFolder", "jdk-11.0.4+11") - .put("javaVersion", "11.0.4+11") - .put("jdk8Folder", UpdateIntelliJSdksTask.JDK_8_FOLDER_NAME) - .put("java8Version", UpdateIntelliJSdksTask.JAVA_8_VERSION) + .put("jdkFolder", "jdk-zulu13.28.11-ca-jdk13.0.1") + .put("javaVersion", "zulu13.28.11-ca-jdk13.0.1") + .put( + "jdk8Folder", "zulu8.42.0.21-ca-jdk8.0.232/zulu8.42.0.21-ca-jdk8.0.232-" + suffix()) + .put("java8Version", "zulu8.42.0.21-ca-jdk8.0.232") .put("goVersion", ToolDependencies.getDefaultVersion("golang")) .build()); } + + private static String suffix() { + switch (new PlatformHelper().getOs()) { + case WINDOWS: + return "win_x64"; + case MAC_OSX: + return "macosx_x64"; + case LINUX: + return "linux_x64"; + default: + throw new IllegalStateException("Unknown OS"); + } + } } diff --git a/tools/gradle-plugins/gradle-curiostack-plugin/src/test/resources/update-intellij-jdks-task-test-tables/existing-and-curio-openjdk.template.xml b/tools/gradle-plugins/gradle-curiostack-plugin/src/test/resources/update-intellij-jdks-task-test-tables/existing-and-curio-openjdk.template.xml index b3307bbaf..5b9584593 100644 --- a/tools/gradle-plugins/gradle-curiostack-plugin/src/test/resources/update-intellij-jdks-task-test-tables/existing-and-curio-openjdk.template.xml +++ b/tools/gradle-plugins/gradle-curiostack-plugin/src/test/resources/update-intellij-jdks-task-test-tables/existing-and-curio-openjdk.template.xml @@ -28,7 +28,7 @@ - + diff --git a/tools/gradle-plugins/gradle-curiostack-plugin/src/test/resources/update-intellij-jdks-task-test-tables/existing-related.xml b/tools/gradle-plugins/gradle-curiostack-plugin/src/test/resources/update-intellij-jdks-task-test-tables/existing-related.xml index 56ac9e3ae..8a0feab94 100644 --- a/tools/gradle-plugins/gradle-curiostack-plugin/src/test/resources/update-intellij-jdks-task-test-tables/existing-related.xml +++ b/tools/gradle-plugins/gradle-curiostack-plugin/src/test/resources/update-intellij-jdks-task-test-tables/existing-related.xml @@ -28,9 +28,9 @@ - + - + diff --git a/tools/gradle-plugins/gradle-curiostack-plugin/src/test/resources/update-intellij-jdks-task-test-tables/only-curio-openjdk.template.xml b/tools/gradle-plugins/gradle-curiostack-plugin/src/test/resources/update-intellij-jdks-task-test-tables/only-curio-openjdk.template.xml index 6bf6c6040..c737331fe 100644 --- a/tools/gradle-plugins/gradle-curiostack-plugin/src/test/resources/update-intellij-jdks-task-test-tables/only-curio-openjdk.template.xml +++ b/tools/gradle-plugins/gradle-curiostack-plugin/src/test/resources/update-intellij-jdks-task-test-tables/only-curio-openjdk.template.xml @@ -1,7 +1,7 @@ - +