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
This commit is contained in:
Leonid Shalupov
2022-08-15 11:16:12 +00:00
committed by intellij-monorepo-bot
parent 5fdbd418c5
commit 8f941b4a9d
2 changed files with 15 additions and 7 deletions
@@ -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.
@@ -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)