From ea9aa44089b623dc2d6fc63bfde2ecc076711153 Mon Sep 17 00:00:00 2001 From: Valery Teplyakov Date: Wed, 29 Jan 2025 18:08:26 +0100 Subject: [PATCH] [fleet, backend] Run backend from sources in 'Dev Server' mode It's lightweight than a real distribution, but do jar packaging GitOrigin-RevId: 8cef5df35a552e7f064cffe157ea6c49a1bfea86 --- .../dev-server/src/DevMainImpl.kt | 41 +++++++++++++------ .../intellij/build/dev/IdeBuilder.kt | 2 +- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/platform/build-scripts/dev-server/src/DevMainImpl.kt b/platform/build-scripts/dev-server/src/DevMainImpl.kt index 868c3e3e09cc..eca4fb0680b6 100644 --- a/platform/build-scripts/dev-server/src/DevMainImpl.kt +++ b/platform/build-scripts/dev-server/src/DevMainImpl.kt @@ -11,8 +11,29 @@ import org.jetbrains.intellij.build.dev.getIdeSystemProperties import org.jetbrains.intellij.build.telemetry.withTracer import java.nio.file.Path -@Suppress("unused", "IO_FILE_USAGE") +data class BuildDevInfo( + val classPath: Collection, + val systemProperties: Map, +) + +@Suppress("unused") fun buildDevMain(): Collection { + val info = buildDevImpl() + + @Suppress("SpellCheckingInspection") + val exceptions = setOf("jna.boot.library.path", "pty4j.preferred.native.folder", "jna.nosys", "jna.noclasspath", "jb.vmOptionsFile") + val systemProperties = System.getProperties() + for ((name, value) in info.systemProperties) { + if (exceptions.contains(name) || !systemProperties.containsKey(name)) { + systemProperties.setProperty(name, value) + } + } + System.setProperty(PathManager.PROPERTY_HOME_PATH, info.systemProperties.getValue(PathManager.PROPERTY_HOME_PATH)) + return info.classPath +} + +@Suppress("IO_FILE_USAGE") +fun buildDevImpl(): BuildDevInfo { //TracerProviderManager.setOutput(Path.of(System.getProperty("user.home"), "trace.json")) @Suppress("TestOnlyProblems") val ideaProjectRoot = Path.of(PathManager.getHomePathFor(PathManager::class.java)!!) @@ -20,6 +41,7 @@ fun buildDevMain(): Collection { var homePath: String? = null var newClassPath: Collection? = null + val environment = mutableMapOf() withTracer(serviceName = "builder") { buildProductInProcess( BuildRequest( @@ -30,15 +52,7 @@ fun buildDevMain(): Collection { platformClassPathConsumer = { classPath, runDir -> newClassPath = classPath homePath = runDir.toString().replace(java.io.File.separator, "/") - - @Suppress("SpellCheckingInspection") - val exceptions = setOf("jna.boot.library.path", "pty4j.preferred.native.folder", "jna.nosys", "jna.noclasspath", "jb.vmOptionsFile") - val systemProperties = System.getProperties() - for ((name, value) in getIdeSystemProperties(runDir).map) { - if (exceptions.contains(name) || !systemProperties.containsKey(name)) { - systemProperties.setProperty(name, value) - } - } + environment.putAll(getIdeSystemProperties(runDir).map) }, generateRuntimeModuleRepository = SystemProperties.getBooleanProperty("intellij.build.generate.runtime.module.repository", false), buildOptionsTemplate = BuildOptions(), @@ -46,9 +60,12 @@ fun buildDevMain(): Collection { ) } homePath?.let { - System.setProperty(PathManager.PROPERTY_HOME_PATH, it) + environment[PathManager.PROPERTY_HOME_PATH] = it } - return newClassPath!! + return BuildDevInfo( + classPath = newClassPath!!, + systemProperties = environment, + ) } private fun getAdditionalPluginMainModules(): List = diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/dev/IdeBuilder.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/dev/IdeBuilder.kt index 313575ba94d1..b530df6f7a05 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/dev/IdeBuilder.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/dev/IdeBuilder.kt @@ -49,7 +49,7 @@ data class BuildRequest( @JvmField val platformPrefix: String, @JvmField val additionalModules: List, @JvmField val projectDir: Path, - @JvmField val devRootDir: Path = projectDir.resolve("out/dev-run"), + @JvmField val devRootDir: Path = System.getProperty("idea.dev.root.dir")?.let { Path.of(it).normalize().toAbsolutePath() } ?: projectDir.resolve("out/dev-run"), @JvmField val jarCacheDir: Path = devRootDir.resolve("jar-cache"), @JvmField val productionClassOutput: Path = System.getenv("CLASSES_DIR")?.let { Path.of(it).normalize().toAbsolutePath() } ?: projectDir.resolve("out/classes/production"), @JvmField val keepHttpClient: Boolean = true,