diff --git a/src/main/java/org/gradle/profiler/studio/launcher/StudioLauncher.java b/src/main/java/org/gradle/profiler/studio/launcher/StudioLauncher.java index cdf942ea..f1188c9c 100644 --- a/src/main/java/org/gradle/profiler/studio/launcher/StudioLauncher.java +++ b/src/main/java/org/gradle/profiler/studio/launcher/StudioLauncher.java @@ -66,6 +66,9 @@ private void logLauncherConfiguration(List commandLine) { System.out.println("* Additional JVM args:"); additionalJvmArgs.forEach(arg -> System.out.println(" " + arg)); System.out.println("* Additional JVM args can be found at: " + studioSandbox.getScenarioOptionsDir().resolve("idea.vmoptions")); + System.out.println("* IDEA properties:"); + ideaProperties.forEach(property -> System.out.println(" " + property)); + System.out.println("* IDEA properties can be found at: " + studioSandbox.getScenarioOptionsDir().resolve("idea.properties")); System.out.println("* Android Studio logs can be found at: " + studioSandbox.getLogsDir().resolve("idea.log")); System.out.printf("* Using command line: %s%n%n", String.join(" ", commandLine)); } diff --git a/src/main/java/org/gradle/profiler/studio/tools/StudioSandboxCreator.java b/src/main/java/org/gradle/profiler/studio/tools/StudioSandboxCreator.java index 2bc07681..574276ea 100644 --- a/src/main/java/org/gradle/profiler/studio/tools/StudioSandboxCreator.java +++ b/src/main/java/org/gradle/profiler/studio/tools/StudioSandboxCreator.java @@ -30,17 +30,17 @@ public static StudioSandbox createSandbox(@Nullable Path sandboxDir, String plug Path path = newTempDir(); Path pluginsDir = createDir(new File(path.toFile(), pluginsDirName).toPath()); Path logsDir = createDir(new File(path.toFile(), "logs").toPath()); - Path jvmArgsDir = createDir(new File(path.toFile(), "jvmArgs").toPath()); - return StudioSandbox.partialSandbox(pluginsDir, logsDir, jvmArgsDir); + Path scenarioOptionsDir = createDir(new File(path.toFile(), "scenarioOptions").toPath()); + return StudioSandbox.partialSandbox(pluginsDir, logsDir, scenarioOptionsDir); } File sandboxDirFile = sandboxDir.toFile(); Path configDir = createDir(new File(sandboxDirFile, "config").toPath()); Path systemDir = createDir(new File(sandboxDirFile, "system").toPath()); Path pluginsDir = createDir(new File(sandboxDirFile, pluginsDirName).toPath()); Path logDir = createDir(new File(sandboxDirFile, "logs").toPath()); - Path jvmArgsDir = createDir(new File(sandboxDirFile, "jvmArgs").toPath()); + Path scenarioOptionsDir = createDir(new File(sandboxDirFile, "scenarioOptions").toPath()); disableIdeUpdate(configDir); - return StudioSandbox.fullSandbox(configDir, systemDir, pluginsDir, logDir, jvmArgsDir); + return StudioSandbox.fullSandbox(configDir, systemDir, pluginsDir, logDir, scenarioOptionsDir); } private static boolean shouldCreatePartialSandbox(Path sandboxDir) { @@ -122,12 +122,12 @@ public Path getPluginsDir() { return pluginsDir; } - public static StudioSandbox fullSandbox(Path configDir, Path systemDir, Path pluginsDir, Path logsDir, Path jvmArgsDir) { - return new StudioSandbox(configDir, systemDir, pluginsDir, logsDir, jvmArgsDir); + public static StudioSandbox fullSandbox(Path configDir, Path systemDir, Path pluginsDir, Path logsDir, Path scenarioOptionsDir) { + return new StudioSandbox(configDir, systemDir, pluginsDir, logsDir, scenarioOptionsDir); } - public static StudioSandbox partialSandbox(Path pluginsDir, Path logsDir, Path jvmArgsDir) { - return new StudioSandbox(null, null, pluginsDir, logsDir, jvmArgsDir); + public static StudioSandbox partialSandbox(Path pluginsDir, Path logsDir, Path scenarioOptionsDir) { + return new StudioSandbox(null, null, pluginsDir, logsDir, scenarioOptionsDir); } } } diff --git a/src/test/groovy/org/gradle/profiler/AndroidStudioIntegrationTest.groovy b/src/test/groovy/org/gradle/profiler/AndroidStudioIntegrationTest.groovy index c6021761..a6a20348 100644 --- a/src/test/groovy/org/gradle/profiler/AndroidStudioIntegrationTest.groovy +++ b/src/test/groovy/org/gradle/profiler/AndroidStudioIntegrationTest.groovy @@ -270,7 +270,7 @@ class AndroidStudioIntegrationTest extends AbstractProfilerIntegrationTest { then: logFile.find("Full sync has completed in").size() == 2 logFile.find("and it SUCCEEDED").size() == 2 - def vmOptionsFile = new File(sandboxDir, "jvmArgs/idea.vmoptions") + def vmOptionsFile = new File(sandboxDir, "scenarioOptions/idea.vmoptions") vmOptionsFile.exists() def vmOptions = vmOptionsFile.readLines() vmOptions.contains("-Xmx1024m") @@ -347,7 +347,7 @@ class AndroidStudioIntegrationTest extends AbstractProfilerIntegrationTest { then: logFile.find("Full sync has completed in").size() == 2 logFile.find("and it SUCCEEDED").size() == 2 - def ideaPropertiesFile = new File(sandboxDir, "config/idea.properties") + def ideaPropertiesFile = new File(sandboxDir, "scenarioOptions/idea.properties") def ideaProperties = ideaPropertiesFile.readLines() ideaProperties.contains("foo=true") } diff --git a/subprojects/studio-plugin/src/main/java/org/gradle/profiler/studio/plugin/GradleProfilerStartupActivity.java b/subprojects/studio-plugin/src/main/java/org/gradle/profiler/studio/plugin/GradleProfilerStartupActivity.java index 0f20276a..46948f06 100644 --- a/subprojects/studio-plugin/src/main/java/org/gradle/profiler/studio/plugin/GradleProfilerStartupActivity.java +++ b/subprojects/studio-plugin/src/main/java/org/gradle/profiler/studio/plugin/GradleProfilerStartupActivity.java @@ -8,6 +8,8 @@ import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsListenerAdapter; import com.intellij.openapi.project.Project; import com.intellij.openapi.startup.StartupActivity; +import com.intellij.openapi.util.registry.Registry; +import com.intellij.openapi.util.registry.RegistryValue; import org.gradle.profiler.client.protocol.Client; import org.gradle.profiler.client.protocol.messages.StudioRequest; import org.gradle.profiler.studio.plugin.client.GradleProfilerClient; @@ -17,9 +19,14 @@ import org.jetbrains.plugins.gradle.settings.GradleProjectSettings; import org.jetbrains.plugins.gradle.settings.GradleSettings; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.UncheckedIOException; import java.util.Collection; +import java.util.List; +import java.util.Properties; +import java.util.stream.Collectors; import static org.gradle.profiler.client.protocol.messages.StudioRequest.StudioRequestType.EXIT_IDE; @@ -32,6 +39,7 @@ public class GradleProfilerStartupActivity implements StartupActivity.DumbAware @Override public void runActivity(@NotNull Project project) { LOG.info("Project opened"); + logModifiedRegistryEntries(); if (System.getProperty(PROFILER_PORT_PROPERTY) != null) { // This solves the issue where Android Studio would run the Gradle sync automatically on the first import. // Unfortunately it seems we can't always detect it because it happens very late and due to that there might @@ -53,6 +61,25 @@ public void runActivity(@NotNull Project project) { } } + private void logModifiedRegistryEntries() { + String studioPropertiesPath = System.getenv("STUDIO_PROPERTIES"); + if (studioPropertiesPath == null || !new File(studioPropertiesPath).exists()) { + return; + } + try { + Properties properties = new Properties(); + properties.load(new FileInputStream(studioPropertiesPath)); + List modifiedValues = Registry.getAll().stream() + .filter(value -> properties.containsKey(value.getKey())) + .map(RegistryValue::toString) + .sorted() + .collect(Collectors.toList()); + LOG.info("Modified registry entries: " + modifiedValues); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + private void disableDownloadOfExternalAnnotations(Project project) { GradleSettings gradleSettings = GradleSettings.getInstance(project); gradleSettings.getLinkedProjectsSettings()