build-scripts: properly log environment into build messages
authorLeonid Shalupov <leonid@shalupov.com>
Sat, 13 Aug 2022 11:48:45 +0000 (13:48 +0200)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Sat, 13 Aug 2022 12:09:41 +0000 (12:09 +0000)
GitOrigin-RevId: e52eb9f362aa0ceae0dbea0c722e83e20234c7d7

platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/CompilationContextImpl.kt

index 56940ddbca64b049fee1e6be44b9c11b81ee3b12..7081c9aeceaa1215ad8055ceb3d7a299a3a3f9bb 100644 (file)
@@ -237,18 +237,17 @@ class CompilationContextImpl private constructor(model: JpsModel,
   override val stableJdkHome: Path
 
   companion object {
-    @JvmStatic
-    fun printEnvironmentDebugInfo() {
+    private fun printEnvironmentDebugInfo(messages: BuildMessages) {
       // 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()) {
-        println("ENV $key = ${env[key]}")
+        messages.info("ENV $key = ${env[key]}")
       }
 
       val properties = System.getProperties()
       for (propertyName in properties.keys.sortedBy { it as String }) {
-        println("PROPERTY $propertyName = ${properties[propertyName].toString()}")
+        messages.info("PROPERTY $propertyName = ${properties[propertyName].toString()}")
       }
     }
 
@@ -264,10 +263,9 @@ class CompilationContextImpl private constructor(model: JpsModel,
         messages.error("communityHome ($communityHome) doesn\'t point to a directory containing IntelliJ Community sources")
       }
       messages.block("Environment info") {
-        // printEnvironmentDebugInfo doesn't use a logger, and prints directly to stdout instead.
-        // Here we log at least something before the main output, so that the block doesn't get omitted as empty.
+        messages.info("Community home: ${communityHome.communityRoot}")
         messages.info("Project home: $projectHome")
-        printEnvironmentDebugInfo()
+        printEnvironmentDebugInfo(messages)
       }
       logFreeDiskSpace(dir = projectHome, phase = "before downloading dependencies")
       val kotlinBinaries = KotlinBinaries(communityHome, options, messages)