From 113df53ce60e0c69b11302256da1d562752578a9 Mon Sep 17 00:00:00 2001 From: Jakub Chrzanowski Date: Thu, 27 Mar 2025 18:35:24 +0100 Subject: [PATCH] tools_intellij_platform_gradle_plugin_recipes.md: Adjust IDE configuration by altering sandbox files --- ...intellij_platform_gradle_plugin_recipes.md | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/topics/appendix/tools/intellij_platform_gradle_plugin/tools_intellij_platform_gradle_plugin_recipes.md b/topics/appendix/tools/intellij_platform_gradle_plugin/tools_intellij_platform_gradle_plugin_recipes.md index f04bfc470..625979831 100644 --- a/topics/appendix/tools/intellij_platform_gradle_plugin/tools_intellij_platform_gradle_plugin_recipes.md +++ b/topics/appendix/tools/intellij_platform_gradle_plugin/tools_intellij_platform_gradle_plugin_recipes.md @@ -196,6 +196,38 @@ tasks { +## Adjust IDE configuration by altering sandbox files + +When starting the IDE locally with [`runIde`](tools_intellij_platform_gradle_plugin_tasks.md#runIde) task or running tests, the IDE creates and updates configuration files within the sandbox directory. +Those files may be related to trusted paths, macros, recent projects, custom plugins, color schemes, etc. +However, when running the `clean` task, all configuration files are wiped and do not persist between sessions. + +Sometimes, it may be worth recreating such configuration, yet with the [`prepareSandbox`](tools_intellij_platform_gradle_plugin_tasks.md#prepareSandbox) task for those configurations to persist. +The following example marks the project located in the $USER_HOME$/IdeaProjects/GradleProject directory as trusted, like when the user clicks on the _Trust Project_ dialog when opening it for the first time. + +```kotlin +tasks.withType { + doLast { + val trustedPathsFile = sandboxConfigDirectory.file("options/trusted-paths.xml").get().asFile + + trustedPathsFile.writeText( + """ + + + + + + """.trimIndent() + ) + } +} +``` + + ## ProGuard configuration To configure [ProGuard](https://github.com/Guardsquare/proguard), intercept the [`prepareSandbox`](tools_intellij_platform_gradle_plugin_tasks.md#prepareSandbox) task and replace the plugin Jar archive produced by the [`composedJar`](tools_intellij_platform_gradle_plugin_tasks.md#composedJar) task with the obfuscated/minified file.