Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
Fix update intellij SDKs task to recognize zulu. (#486)
Browse files Browse the repository at this point in the history
* Fix update intellij SDKs task to recognize zulu.

* Fix test

* Revert typo

* Fix test

* Actually fix
  • Loading branch information
chokoswitch authored Nov 23, 2019
1 parent c714aa2 commit 7006be5
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 24 deletions.
1 change: 1 addition & 0 deletions common/web/base-node-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
"typescript": "3.7.2"
}
}

2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CuriostackExtension> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
# SOFTWARE.
#

version = 0.1.0
version = 0.1.1
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> JAVA_MODULES =
ImmutableList.of(
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<jdk version="2">
<name value="11" />
<name value="{{ majorVersion }}" />
<type value="JavaSDK" />
<version value="java version &quot;{{ javaVersion }}&quot;" />
<homePath value="{{ jdkFolder }}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -204,11 +204,25 @@ private String testTemplate(String path) {
template,
ImmutableMap.<String, Object>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");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<additional />
</jdk>
<jdk version="2">
<name value="11" />
<name value="13" />
<type value="JavaSDK" />
<version value="java version &quot;{{ javaVersion }}&quot;" />
<homePath value="{{ gradleHome }}/curiostack/openjdk/{{ jdkFolder }}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
<additional />
</jdk>
<jdk version="2">
<name value="11" />
<name value="13" />
<type value="JavaSDK" />
<version value="java version &quot;11.0.old&quot;" />
<version value="java version &quot;13.0.old&quot;" />
<homePath value="a/folder/we/ignore/curiostack/openjdk/openjdk-old" />
<roots>
<annotationsPath>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<application>
<component name="ProjectJdkTable">
<jdk version="2">
<name value="11" />
<name value="13" />
<type value="JavaSDK" />
<version value="java version &quot;{{ javaVersion }}&quot;" />
<homePath value="{{ gradleHome }}/curiostack/openjdk/{{ jdkFolder }}" />
Expand Down

0 comments on commit 7006be5

Please sign in to comment.