From 8f941b4a9d727149554780e7fc2993ab84dd4ec3 Mon Sep 17 00:00:00 2001 From: Leonid Shalupov Date: Mon, 15 Aug 2022 13:07:36 +0200 Subject: [PATCH] build-scripts: hide environment logging under system property `intellij.print.environment` (disabled by default) Days of build scripts environment debugging are mostly behind us and a lot of debugging output interferes with other activities GitOrigin-RevId: 243a9ae6a37a0b65130b0177faa24e5161c85b32 --- .../org/jetbrains/intellij/build/BuildOptions.kt | 6 ++++++ .../build/impl/CompilationContextImpl.kt | 16 +++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/BuildOptions.kt b/platform/build-scripts/groovy/org/jetbrains/intellij/build/BuildOptions.kt index 4ad52656eeee..2f52dae08e83 100644 --- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/BuildOptions.kt +++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/BuildOptions.kt @@ -267,6 +267,12 @@ class BuildOptions { var isTestBuild = SystemProperties.getBooleanProperty("intellij.build.test.mode", false) var skipDependencySetup = false + /** + * If 'true' print system properties and environment variables to stdout. + * Mostly useful for build scripts debugging. + */ + var printEnvironmentInfo = SystemProperties.getBooleanProperty("intellij.print.environment", false) + /** * Specifies list of names of directories of bundled plugins which shouldn't be included into the product distribution. This option can be * used to speed up updating the IDE from sources. diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/CompilationContextImpl.kt b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/CompilationContextImpl.kt index 7081c9aeceaa..5aa2ff7621c4 100644 --- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/CompilationContextImpl.kt +++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/CompilationContextImpl.kt @@ -237,17 +237,17 @@ class CompilationContextImpl private constructor(model: JpsModel, override val stableJdkHome: Path companion object { - private fun printEnvironmentDebugInfo(messages: BuildMessages) { + private fun printEnvironmentDebugInfo() { // print it to the stdout since TeamCity will remove any sensitive fields from build log automatically // don't write it to debug log file! val env = System.getenv() for (key in env.keys.sorted()) { - messages.info("ENV $key = ${env[key]}") + println("ENV $key = ${env[key]}") } val properties = System.getProperties() for (propertyName in properties.keys.sortedBy { it as String }) { - messages.info("PROPERTY $propertyName = ${properties[propertyName].toString()}") + println("PROPERTY $propertyName = ${properties[propertyName].toString()}") } } @@ -262,10 +262,12 @@ class CompilationContextImpl private constructor(model: JpsModel, if (sequenceOf("platform/build-scripts", "bin/idea.properties", "build.txt").any { !Files.exists(communityHome.communityRoot.resolve(it)) }) { messages.error("communityHome ($communityHome) doesn\'t point to a directory containing IntelliJ Community sources") } - messages.block("Environment info") { - messages.info("Community home: ${communityHome.communityRoot}") - messages.info("Project home: $projectHome") - printEnvironmentDebugInfo(messages) + if (options.printEnvironmentInfo) { + messages.block("Environment info") { + messages.info("Community home: ${communityHome.communityRoot}") + messages.info("Project home: $projectHome") + printEnvironmentDebugInfo() + } } logFreeDiskSpace(dir = projectHome, phase = "before downloading dependencies") val kotlinBinaries = KotlinBinaries(communityHome, options, messages)