Skip to content

Commit

Permalink
Add support for IntelliJ IDEA Ultimate (#111)
Browse files Browse the repository at this point in the history
Fixes #77

Signed-off-by: Zbynek Cervinka <[email protected]>
  • Loading branch information
zcervink authored May 9, 2022
1 parent 9743c40 commit 1c146b2
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ public static RemoteRobot runIde(IdeaVersion ideaVersion, int port) {

return step("Start IntelliJ Idea ('" + ideaVersion.toString() + "') listening on port " + port, () -> {
UITestRunner.ideaVersion = ideaVersion;
makeSureAllTermsAndConditionsAreAccepted();
acceptAllTermsAndConditions();

if (ideaVersion.isUltimate()) {
activateEvaluateForFree();
}

String fileExtension = OS_NAME.contains("windows") ? ".bat" : "";
ProcessBuilder pb = new ProcessBuilder("." + File.separator + "gradlew" + fileExtension, "runIdeForUiTests", "-PideaVersion=" + ideaVersion.toString(), "-Drobot-server.port=" + port);
Expand Down Expand Up @@ -154,8 +158,7 @@ public enum IdeaVersion {
ULTIMATE_V_2020_2("IU-2020.2"),
ULTIMATE_V_2020_3("IU-2020.3"),
ULTIMATE_V_2021_1("IU-2021.1"),
ULTIMATE_V_2021_2("IU-2021.2"),
ULTIMATE_V_2021_3("IU-2021.3");
ULTIMATE_V_2021_2("IU-2021.2");

private final String ideaVersionStringRepresentation;

Expand All @@ -172,12 +175,21 @@ public int toInt() {
String ideaVersion = this.ideaVersionStringRepresentation.substring(3).replace(".", "");
return Integer.parseInt(ideaVersion);
}

public boolean isUltimate() {
return this.ideaVersionStringRepresentation.charAt(1) == 'U';
}
}

private static void makeSureAllTermsAndConditionsAreAccepted() {
private static void acceptAllTermsAndConditions() {
if (OS_NAME.contains("linux")) {
step("Copy the 'prefs.xml' file to the appropriate location", () -> {
String prefsXmlSourceLocation = "prefs.xml";
String prefsXmlSourceLocation;
if (!ideaVersion.isUltimate()) {
prefsXmlSourceLocation = "prefs.xml";
} else {
prefsXmlSourceLocation = "prefs_xml/ultimate_all/prefs.xml";
}
String prefsXmlDir = USER_HOME + "/.java/.userPrefs/jetbrains/_!(!!cg\"p!(}!}@\"j!(k!|w\"w!'8!b!\"p!':!e@==";
createDirectoryHierarchy(prefsXmlDir);
copyFileFromJarResourceDir(prefsXmlSourceLocation, prefsXmlDir + "/prefs.xml");
Expand All @@ -190,7 +202,12 @@ private static void makeSureAllTermsAndConditionsAreAccepted() {
});
} else if (OS_NAME.contains("os x")) {
step("Copy the 'com.apple.java.util.prefs.plist' file to the appropriate location", () -> {
String plistSourceLocation = "com.apple.java.util.prefs.plist";
String plistSourceLocation;
if (!ideaVersion.isUltimate()) {
plistSourceLocation = "com.apple.java.util.prefs.plist";
} else {
plistSourceLocation = "plist/ultimate_all/com.apple.java.util.prefs.plist";
}
String plistDir = USER_HOME + "/Library/Preferences";
copyFileFromJarResourceDir(plistSourceLocation, plistDir + "/com.apple.java.util.prefs.plist");
});
Expand Down Expand Up @@ -224,6 +241,7 @@ private static void makeSureAllTermsAndConditionsAreAccepted() {
ProcessBuilder pb1 = new ProcessBuilder(powershellLocation, "New-Item", powershellPathParameter, registryPath, "-Force");
ProcessBuilder pb2 = new ProcessBuilder(powershellLocation, "New-ItemProperty", powershellPathParameter, registryPath, "-Name", "accepted_version", "-Value", "'2.1'");
ProcessBuilder pb3 = new ProcessBuilder(powershellLocation, "New-ItemProperty", powershellPathParameter, registryPath, "-Name", "euacommunity_accepted_version", "-Value", "'1.0'");
ProcessBuilder pb4 = new ProcessBuilder(powershellLocation, "New-ItemProperty", powershellPathParameter, registryPath, "-Name", "eua_accepted_version", "-Value", "'1.2'");

try {
Process p1 = pb1.start();
Expand All @@ -232,6 +250,8 @@ private static void makeSureAllTermsAndConditionsAreAccepted() {
p2.waitFor();
Process p3 = pb3.start();
p3.waitFor();
Process p4 = pb4.start();
p4.waitFor();
} catch (IOException | InterruptedException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
Thread.currentThread().interrupt();
Expand All @@ -240,6 +260,18 @@ private static void makeSureAllTermsAndConditionsAreAccepted() {
}
}

private static void activateEvaluateForFree() {
String targetEvaluationKeysDir = System.getProperty("user.dir") + "/build/idea-sandbox/config-uiTest/eval/";
createDirectoryHierarchy(targetEvaluationKeysDir);

for (String ideaVersionSubstring : new String[]{"202", "203", "211", "212"}) {
String keyFilename = "idea" + ideaVersionSubstring + ".evaluation.key";
String sourcePathToKey = "evaluate_for_free_keys/" + keyFilename;
String targetPathToKey = targetEvaluationKeysDir + keyFilename;
copyFileFromJarResourceDir(sourcePathToKey, targetPathToKey);
}
}

private static void waitUntilIntelliJStarts(int port) {
waitFor(Duration.ofSeconds(600), Duration.ofSeconds(3), "The IntelliJ Idea did not start in 10 minutes.", () -> isIntelliJUIVisible(port));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
������
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�����D�
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
������^
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�����&
Binary file not shown.
6 changes: 6 additions & 0 deletions src/main/resources/prefs_xml/ultimate_all/prefs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE map SYSTEM "http://java.sun.com/dtd/preferences.dtd">
<map MAP_XML_VERSION="1.0">
<entry key="eua_accepted_version" value="1.2"/>
<entry key="euacommunity_accepted_version" value="1.0"/>
</map>
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
public class LibraryTestBase {
protected static RemoteRobot remoteRobot;
private static boolean intelliJHasStarted = false;
private static UITestRunner.IdeaVersion ideaVersion = UITestRunner.IdeaVersion.COMMUNITY_V_2021_1;
private static UITestRunner.IdeaVersion ideaVersion = UITestRunner.IdeaVersion.ULTIMATE_V_2021_1;
protected static int ideaVersionInt = ideaVersion.toInt();
protected static final Logger LOGGER = Logger.getLogger(LibraryTestBase.class.getName());

Expand Down

0 comments on commit 1c146b2

Please sign in to comment.