Move kotlin-build-statistic project to :compiler

This commit is contained in:
Nataliya.Valtman
2023-04-18 03:49:29 +02:00
committed by Space Team
parent e34dd043da
commit 2a391f7330
53 changed files with 166 additions and 249 deletions
+2 -2
View File
@@ -19,14 +19,14 @@ dependencies {
compileOnly(intellijCore()) compileOnly(intellijCore())
compileOnly(commonDependency("org.jetbrains.intellij.deps:asm-all")) compileOnly(commonDependency("org.jetbrains.intellij.deps:asm-all"))
compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j")) compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j"))
compileOnly(project(":kotlin-build-statistic")) compileOnly(project(":compiler:build-tools:kotlin-build-statistics"))
testCompileOnly(project(":compiler:cli-common")) testCompileOnly(project(":compiler:cli-common"))
testApi(projectTests(":compiler:tests-common")) testApi(projectTests(":compiler:tests-common"))
testApi(commonDependency("junit:junit")) testApi(commonDependency("junit:junit"))
testApi(protobufFull()) testApi(protobufFull())
testApi(kotlinStdlib()) testApi(kotlinStdlib())
testImplementation(project(":kotlin-build-statistic")) testImplementation(project(":compiler:build-tools:kotlin-build-statistics"))
testImplementation(commonDependency("org.jetbrains.kotlin:kotlin-reflect")) { isTransitive = false } testImplementation(commonDependency("org.jetbrains.kotlin:kotlin-reflect")) { isTransitive = false }
testImplementation("org.reflections:reflections:0.10.2") testImplementation("org.reflections:reflections:0.10.2")
} }
+2 -2
View File
@@ -143,7 +143,7 @@ val commonCompilerModules = arrayOf(
":analysis:project-structure", ":analysis:project-structure",
":analysis:kt-references", ":analysis:kt-references",
":kotlin-build-common", ":kotlin-build-common",
":kotlin-build-statistic", ":compiler:build-tools:kotlin-build-statistics",
).also { extra["commonCompilerModules"] = it } ).also { extra["commonCompilerModules"] = it }
val firCompilerCoreModules = arrayOf( val firCompilerCoreModules = arrayOf(
@@ -264,7 +264,7 @@ extra["kotlinJpsPluginMavenDependencies"] = listOf(
":kotlin-util-klib", ":kotlin-util-klib",
":kotlin-util-klib-metadata", ":kotlin-util-klib-metadata",
":native:kotlin-native-utils", ":native:kotlin-native-utils",
":kotlin-build-statistic", ":compiler:build-tools:kotlin-build-statistics",
) )
extra["kotlinJpsPluginMavenDependenciesNonTransitiveLibs"] = listOf( extra["kotlinJpsPluginMavenDependenciesNonTransitiveLibs"] = listOf(
-1
View File
@@ -81,7 +81,6 @@ val kotlinGradlePluginAndItsRequired = arrayOf(
":native:kotlin-klib-commonizer-api", ":native:kotlin-klib-commonizer-api",
":compiler:build-tools:kotlin-build-tools-api", ":compiler:build-tools:kotlin-build-tools-api",
":compiler:build-tools:kotlin-build-tools-impl", ":compiler:build-tools:kotlin-build-tools-impl",
":compiler:kotlin-build-statistic"
) )
fun Task.dependsOnKotlinGradlePluginInstall() { fun Task.dependsOnKotlinGradlePluginInstall() {
@@ -25,23 +25,4 @@ sourceSets {
"test" { projectDefault() } "test" { projectDefault() }
} }
publish() projectTest(jUnitMode = JUnitMode.JUnit5, parallel = true)
runtimeJar()
sourcesJar()
javadocJar()
testsJar()
projectTest(parallel = true)
projectTest("testJUnit5", jUnitMode = JUnitMode.JUnit5, parallel = true) {
useJUnitPlatform()
}
// 1.9 level breaks Kotlin Gradle plugins via changes in enums (KT-48872)
// We limit api and LV until KGP will stop using Kotlin compiler directly (KT-56574)
tasks.withType<KotlinCompilationTask<*>>().configureEach {
compilerOptions.apiVersion.value(GradleKotlinVersion.KOTLIN_1_8).finalizeValueOnRead()
compilerOptions.languageVersion.value(GradleKotlinVersion.KOTLIN_1_8).finalizeValueOnRead()
}
@@ -3,7 +3,7 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
package org.jetbrains.kotlin.build.report.statistic package org.jetbrains.kotlin.build.report.statistics
import org.jetbrains.kotlin.build.report.metrics.BuildAttribute import org.jetbrains.kotlin.build.report.metrics.BuildAttribute
import org.jetbrains.kotlin.build.report.metrics.BuildPerformanceMetric import org.jetbrains.kotlin.build.report.metrics.BuildPerformanceMetric
@@ -66,18 +66,18 @@ enum class BuildDataType {
} }
//Sensitive data. This object is used directly for statistic via http //Sensitive data. This object is used directly for statistic via http
data class GradleBuildStartParameters( data class BuildStartParameters(
val tasks: List<String>, val tasks: List<String>,
val excludedTasks: Set<String>, val excludedTasks: Set<String> = emptySet(),
val currentDir: String?, val currentDir: String? = null,
val projectProperties: List<String>, val projectProperties: List<String> = emptyList(),
val systemProperties: List<String>, val systemProperties: List<String> = emptyList(),
) : java.io.Serializable ) : java.io.Serializable
//Sensitive data. This object is used directly for statistic via http //Sensitive data. This object is used directly for statistic via http
data class BuildFinishStatisticsData( data class BuildFinishStatisticsData(
val projectName: String, val projectName: String,
val startParameters: GradleBuildStartParameters, val startParameters: BuildStartParameters,
val buildUuid: String = "Unset", val buildUuid: String = "Unset",
val label: String?, val label: String?,
val totalTime: Long, val totalTime: Long,
@@ -3,10 +3,10 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
package org.jetbrains.kotlin.build.report.statistic package org.jetbrains.kotlin.build.report.statistics
import com.google.gson.Gson import com.google.gson.Gson
import org.jetbrains.kotlin.util.Logger import org.jetbrains.kotlin.compilerRunner.KotlinLogger
import java.io.IOException import java.io.IOException
import java.io.Serializable import java.io.Serializable
import java.net.HttpURLConnection import java.net.HttpURLConnection
@@ -14,31 +14,29 @@ import java.net.URL
import java.util.* import java.util.*
import kotlin.system.measureTimeMillis import kotlin.system.measureTimeMillis
interface HttpReportService { class HttpReportService(
fun sendData(data: Any, log: Logger)
}
class HttpReportServiceImpl(
private val url: String, private val url: String,
private val password: String?, private val password: String?,
private val user: String?, private val user: String?,
) : HttpReportService, Serializable { ) : Serializable {
private var invalidUrl = false private var invalidUrl = false
private var requestPreviousFailed = false private var requestPreviousFailed = false
private fun checkResponseAndLog(connection: HttpURLConnection, log: Logger) { private fun checkResponseAndLog(connection: HttpURLConnection, log: KotlinLogger) {
val isResponseBad = connection.responseCode !in 200..299 val isResponseBad = connection.responseCode !in 200..299
if (isResponseBad) { if (isResponseBad) {
val message = "Failed to send statistic to ${connection.url} with ${connection.responseCode}: ${connection.responseMessage}" val message = "Failed to send statistic to ${connection.url} with ${connection.responseCode}: ${connection.responseMessage}"
if (!requestPreviousFailed) { if (!requestPreviousFailed) {
log.warning(message) log.warn(message)
} else {
log.debug(message)
} }
requestPreviousFailed = true requestPreviousFailed = true
} }
} }
override fun sendData(data: Any, log: Logger) { fun sendData(data: Any, log: KotlinLogger) {
val elapsedTime = measureTimeMillis { val elapsedTime = measureTimeMillis {
if (invalidUrl) { if (invalidUrl) {
return return
@@ -46,7 +44,7 @@ class HttpReportServiceImpl(
val connection = try { val connection = try {
URL(url).openConnection() as HttpURLConnection URL(url).openConnection() as HttpURLConnection
} catch (e: IOException) { } catch (e: IOException) {
log.warning("Unable to open connection to ${url}: ${e.message}") log.warn("Unable to open connection to ${url}: ${e.message}")
invalidUrl = true invalidUrl = true
return return
} }
@@ -67,12 +65,12 @@ class HttpReportServiceImpl(
connection.connect() connection.connect()
checkResponseAndLog(connection, log) checkResponseAndLog(connection, log)
} catch (e: Exception) { } catch (e: Exception) {
log.warning("Unexpected exception happened ${e.message}: ${e.stackTrace}") log.warn("Unexpected exception happened ${e.message}: ${e.stackTrace}")
checkResponseAndLog(connection, log) checkResponseAndLog(connection, log)
} finally { } finally {
connection.disconnect() connection.disconnect()
} }
} }
log.log("Report statistic by http takes $elapsedTime ms") log.debug("Report statistic by http takes $elapsedTime ms")
} }
} }
@@ -3,15 +3,13 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
package org.jetbrains.kotlin.build.report.statistic.file package org.jetbrains.kotlin.build.report.statistics.file
import org.jetbrains.kotlin.build.report.metrics.* import org.jetbrains.kotlin.build.report.metrics.*
import org.jetbrains.kotlin.build.report.statistic.asString import org.jetbrains.kotlin.build.report.statistics.*
import org.jetbrains.kotlin.build.report.statistic.formatSize import org.jetbrains.kotlin.build.report.statistics.asString
import org.jetbrains.kotlin.build.report.statistic.formatTime import org.jetbrains.kotlin.build.report.statistics.formatTime
import org.jetbrains.kotlin.build.report.statistic.CompileStatisticsData import org.jetbrains.kotlin.compilerRunner.KotlinLogger
import org.jetbrains.kotlin.build.report.statistic.GradleBuildStartParameters
import org.jetbrains.kotlin.util.Logger
import java.io.File import java.io.File
import java.io.Serializable import java.io.Serializable
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
@@ -20,7 +18,7 @@ import java.util.*
class FileReportService( class FileReportService(
private val outputFile: File, private val outputFile: File,
private val printMetrics: Boolean, private val printMetrics: Boolean,
private val logger: Logger private val logger: KotlinLogger
) : Serializable { ) : Serializable {
companion object { companion object {
private val formatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").also { it.timeZone = TimeZone.getTimeZone("UTC")} private val formatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").also { it.timeZone = TimeZone.getTimeZone("UTC")}
@@ -29,9 +27,9 @@ class FileReportService(
projectName: String, projectName: String,
includeMetricsInReport: Boolean, includeMetricsInReport: Boolean,
buildData: List<CompileStatisticsData>, buildData: List<CompileStatisticsData>,
startParameters: GradleBuildStartParameters, startParameters: BuildStartParameters,
failureMessages: List<String>, failureMessages: List<String>,
logger: Logger logger: KotlinLogger
) { ) {
val ts = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(Calendar.getInstance().time) val ts = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(Calendar.getInstance().time)
val reportFile = buildReportDir.resolve("$projectName-build-$ts.txt") val reportFile = buildReportDir.resolve("$projectName-build-$ts.txt")
@@ -48,8 +46,8 @@ class FileReportService(
fun process( fun process(
statisticsData: List<CompileStatisticsData>, statisticsData: List<CompileStatisticsData>,
startParameters: GradleBuildStartParameters, startParameters: BuildStartParameters,
failureMessages: List<String> failureMessages: List<String> = emptyList()
) { ) {
val buildReportPath = outputFile.toPath().toUri().toString() val buildReportPath = outputFile.toPath().toUri().toString()
try { try {
@@ -72,7 +70,7 @@ class FileReportService(
private fun printBuildReport( private fun printBuildReport(
statisticsData: List<CompileStatisticsData>, statisticsData: List<CompileStatisticsData>,
startParameters: GradleBuildStartParameters, startParameters: BuildStartParameters,
failureMessages: List<String> failureMessages: List<String>
) { ) {
// NOTE: BuildExecutionData / BuildOperationRecord contains data for both tasks and transforms. // NOTE: BuildExecutionData / BuildOperationRecord contains data for both tasks and transforms.
@@ -97,7 +95,7 @@ class FileReportService(
printTasksLog(statisticsData) printTasksLog(statisticsData)
} }
private fun printBuildInfo(startParameters: GradleBuildStartParameters, failureMessages: List<String>) { private fun printBuildInfo(startParameters: BuildStartParameters, failureMessages: List<String>) {
p.withIndent("Gradle start parameters:") { p.withIndent("Gradle start parameters:") {
startParameters.let { startParameters.let {
p.println("tasks = ${it.tasks}") p.println("tasks = ${it.tasks}")
@@ -3,7 +3,7 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
package org.jetbrains.kotlin.build.report.statistic.file package org.jetbrains.kotlin.build.report.statistics.file
import java.util.* import java.util.*
import kotlin.math.max import kotlin.math.max
@@ -3,7 +3,7 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
package org.jetbrains.kotlin.build.report.statistic.file package org.jetbrains.kotlin.build.report.statistics.file
import java.io.IOException import java.io.IOException
@@ -3,7 +3,7 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
package org.jetbrains.kotlin.build.report.statistic package org.jetbrains.kotlin.build.report.statistics
internal fun formatTime(ms: Long): String { internal fun formatTime(ms: Long): String {
val seconds = ms.toDouble() / 1_000 val seconds = ms.toDouble() / 1_000
@@ -14,7 +14,7 @@ private const val kbSize = 1024
private const val mbSize = kbSize * 1024 private const val mbSize = kbSize * 1024
private const val gbSize = mbSize * 1024 private const val gbSize = mbSize * 1024
public fun formatSize(sizeInBytes: Long): String = when { fun formatSize(sizeInBytes: Long): String = when {
sizeInBytes / gbSize >= 1 -> "${(sizeInBytes.toDouble() / gbSize).asString(1)} GB" sizeInBytes / gbSize >= 1 -> "${(sizeInBytes.toDouble() / gbSize).asString(1)} GB"
sizeInBytes / mbSize >= 1 -> "${(sizeInBytes.toDouble() / mbSize).asString(1)} MB" sizeInBytes / mbSize >= 1 -> "${(sizeInBytes.toDouble() / mbSize).asString(1)} MB"
sizeInBytes / kbSize >= 1 -> "${(sizeInBytes.toDouble() / kbSize).asString(1)} KB" sizeInBytes / kbSize >= 1 -> "${(sizeInBytes.toDouble() / kbSize).asString(1)} KB"
@@ -26,12 +26,7 @@ import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.isSubpackageOf import org.jetbrains.kotlin.name.isSubpackageOf
import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.util.Logger import org.jetbrains.kotlin.util.Logger
import org.jetbrains.kotlin.utils.KotlinPaths
import java.io.ByteArrayOutputStream
import java.io.File import java.io.File
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
import java.util.zip.ZipOutputStream
import kotlin.system.exitProcess import kotlin.system.exitProcess
fun incrementalCompilationIsEnabled(arguments: CommonCompilerArguments): Boolean { fun incrementalCompilationIsEnabled(arguments: CommonCompilerArguments): Boolean {
@@ -87,7 +82,7 @@ fun <PathProvider : Any> getLibraryFromHome(
fun MessageCollector.toLogger(): Logger = fun MessageCollector.toLogger(): Logger =
object : Logger { object : Logger {
override fun error(message: String, throwable: Throwable?) { override fun error(message: String) {
report(CompilerMessageSeverity.ERROR, message) report(CompilerMessageSeverity.ERROR, message)
} }
@@ -103,9 +98,5 @@ fun MessageCollector.toLogger(): Logger =
override fun log(message: String) { override fun log(message: String) {
report(CompilerMessageSeverity.LOGGING, message) report(CompilerMessageSeverity.LOGGING, message)
} }
override fun lifecycle(message: String) {
report(CompilerMessageSeverity.INFO, message)
}
} }
@@ -18,7 +18,7 @@ dependencies {
api(project(":compiler:backend.jvm.entrypoint")) api(project(":compiler:backend.jvm.entrypoint"))
api(project(":kotlin-build-common")) api(project(":kotlin-build-common"))
api(project(":daemon-common")) api(project(":daemon-common"))
api(project(":kotlin-build-statistic")) api(project(":compiler:build-tools:kotlin-build-statistics"))
compileOnly(intellijCore()) compileOnly(intellijCore())
testApi(commonDependency("junit:junit")) testApi(commonDependency("junit:junit"))
@@ -29,7 +29,6 @@ dependencies {
testApi(intellijCore()) testApi(intellijCore())
testApi(commonDependency("org.jetbrains.intellij.deps:log4j")) testApi(commonDependency("org.jetbrains.intellij.deps:log4j"))
testApi(commonDependency("org.jetbrains.intellij.deps:jdom")) testApi(commonDependency("org.jetbrains.intellij.deps:jdom"))
testApi(projectTests(":kotlin-build-statistic"))
testImplementation(commonDependency("com.google.code.gson:gson")) testImplementation(commonDependency("com.google.code.gson:gson"))
testRuntimeOnly(commonDependency("org.jetbrains.kotlin:kotlin-reflect")) { isTransitive = false } testRuntimeOnly(commonDependency("org.jetbrains.kotlin:kotlin-reflect")) { isTransitive = false }
@@ -106,9 +106,8 @@ val CompilerConfiguration.resolverLogger: Logger
null -> DummyLogger null -> DummyLogger
else -> object : Logger { else -> object : Logger {
override fun log(message: String) = messageLogger.report(IrMessageLogger.Severity.INFO, message, null) override fun log(message: String) = messageLogger.report(IrMessageLogger.Severity.INFO, message, null)
override fun error(message: String, throwable: Throwable?) = messageLogger.report(IrMessageLogger.Severity.ERROR, message, null) override fun error(message: String) = messageLogger.report(IrMessageLogger.Severity.ERROR, message, null)
override fun warning(message: String) = messageLogger.report(IrMessageLogger.Severity.WARNING, message, null) override fun warning(message: String) = messageLogger.report(IrMessageLogger.Severity.WARNING, message, null)
override fun lifecycle(message: String) = messageLogger.report(IrMessageLogger.Severity.INFO, message, null)
override fun fatal(message: String): Nothing { override fun fatal(message: String): Nothing {
messageLogger.report(IrMessageLogger.Severity.ERROR, message, null) messageLogger.report(IrMessageLogger.Severity.ERROR, message, null)
@@ -175,9 +175,8 @@ object GenerationUtils {
fun messageCollectorLogger(collector: MessageCollector) = object : Logger { fun messageCollectorLogger(collector: MessageCollector) = object : Logger {
override fun warning(message: String) = collector.report(CompilerMessageSeverity.STRONG_WARNING, message) override fun warning(message: String) = collector.report(CompilerMessageSeverity.STRONG_WARNING, message)
override fun error(message: String, throwable: Throwable?) = collector.report(CompilerMessageSeverity.ERROR, message) override fun error(message: String) = collector.report(CompilerMessageSeverity.ERROR, message)
override fun log(message: String) = collector.report(CompilerMessageSeverity.LOGGING, message) override fun log(message: String) = collector.report(CompilerMessageSeverity.LOGGING, message)
override fun lifecycle(message: String) = collector.report(CompilerMessageSeverity.INFO, message)
override fun fatal(message: String): Nothing { override fun fatal(message: String): Nothing {
collector.report(CompilerMessageSeverity.ERROR, message) collector.report(CompilerMessageSeverity.ERROR, message)
(collector as? GroupingMessageCollector)?.flush() (collector as? GroupingMessageCollector)?.flush()
@@ -4,10 +4,9 @@ import kotlin.system.exitProcess
interface Logger { interface Logger {
fun log(message: String) fun log(message: String)
fun error(message: String, throwable: Throwable? = null) fun error(message: String)
fun warning(message: String) fun warning(message: String)
fun fatal(message: String): Nothing fun fatal(message: String): Nothing
fun lifecycle(message: String)
} }
interface WithLogger { interface WithLogger {
@@ -16,18 +15,10 @@ interface WithLogger {
object DummyLogger : Logger { object DummyLogger : Logger {
override fun log(message: String) = println(message) override fun log(message: String) = println(message)
override fun error(message: String, throwable: Throwable?) { override fun error(message: String) = println("e: $message")
println("e: $message")
throwable?.also {
println("${it.message}:\n${it.stackTraceToString()} ")
}
}
override fun warning(message: String) = println("w: $message") override fun warning(message: String) = println("w: $message")
override fun fatal(message: String): Nothing { override fun fatal(message: String): Nothing {
println("e: $message") println("e: $message")
exitProcess(1) exitProcess(1)
} }
override fun lifecycle(message: String) = println("i: $message")
} }
@@ -16,10 +16,9 @@ fun resolveSingleFileKlib(
libraryFile: File, libraryFile: File,
logger: Logger = object : Logger { logger: Logger = object : Logger {
override fun log(message: String) {} override fun log(message: String) {}
override fun error(message: String, throwable: Throwable?) = kotlin.error("e: $message") override fun error(message: String) = kotlin.error("e: $message")
override fun warning(message: String) {} override fun warning(message: String) {}
override fun fatal(message: String) = kotlin.error("e: $message") override fun fatal(message: String) = kotlin.error("e: $message")
override fun lifecycle(message: String) {}
}, },
strategy: SingleFileKlibResolveStrategy = CompilerSingleFileKlibResolveStrategy strategy: SingleFileKlibResolveStrategy = CompilerSingleFileKlibResolveStrategy
): KotlinLibrary = strategy.resolve(libraryFile, logger) ): KotlinLibrary = strategy.resolve(libraryFile, logger)
@@ -1,14 +1,15 @@
/* /*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
package org.jetbrains.kotlin.compilerRunner package org.jetbrains.kotlin.compilerRunner
interface KotlinLogger { interface KotlinLogger {
fun error(msg: String) val isDebugEnabled: Boolean
fun error(msg: String, throwable: Throwable? = null)
fun warn(msg: String) fun warn(msg: String)
fun info(msg: String) fun info(msg: String)
fun debug(msg: String) fun debug(msg: String)
val isDebugEnabled: Boolean fun lifecycle(msg: String)
} }
+3 -4
View File
@@ -17,10 +17,9 @@
<trust group="org.jetbrains.kotlin" name="kotlin-annotation-processing-embeddable" version="1.9.[0-9](-.+)?" regex="true"/> <trust group="org.jetbrains.kotlin" name="kotlin-annotation-processing-embeddable" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-annotation-processing-gradle" version="1.9.[0-9](-.+)?" regex="true"/> <trust group="org.jetbrains.kotlin" name="kotlin-annotation-processing-gradle" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-build-common" version="1.9.[0-9](-.+)?" regex="true"/> <trust group="org.jetbrains.kotlin" name="kotlin-build-common" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-build-tools-enum-compat" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-build-tools-api" version="1.9.[0-9](-.+)?" regex="true"/> <trust group="org.jetbrains.kotlin" name="kotlin-build-tools-api" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-build-tools-enum-compat" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-build-tools-impl" version="1.9.[0-9](-.+)?" regex="true"/> <trust group="org.jetbrains.kotlin" name="kotlin-build-tools-impl" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-build-statistic" version="1.9.0.*" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-compiler-embeddable" version="1.9.[0-9](-.+)?" regex="true"/> <trust group="org.jetbrains.kotlin" name="kotlin-compiler-embeddable" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-compiler-runner" version="1.9.[0-9](-.+)?" regex="true"/> <trust group="org.jetbrains.kotlin" name="kotlin-compiler-runner" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-daemon-client" version="1.9.[0-9](-.+)?" regex="true"/> <trust group="org.jetbrains.kotlin" name="kotlin-daemon-client" version="1.9.[0-9](-.+)?" regex="true"/>
@@ -46,8 +45,6 @@
<trust group="org.jetbrains.kotlin" name="kotlin-scripting-jvm" version="1.9.[0-9](-.+)?" regex="true"/> <trust group="org.jetbrains.kotlin" name="kotlin-scripting-jvm" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-serialization" version="1.9.[0-9](-.+)?" regex="true"/> <trust group="org.jetbrains.kotlin" name="kotlin-serialization" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-serialization-unshaded" version="1.9.[0-9](-.+)?" regex="true"/> <trust group="org.jetbrains.kotlin" name="kotlin-serialization-unshaded" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlinx-serialization-compiler-plugin" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlinx-serialization-compiler-plugin-embeddable" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-stdlib" version="1.9.[0-9](-.+)?" regex="true"/> <trust group="org.jetbrains.kotlin" name="kotlin-stdlib" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-stdlib-common" version="1.9.[0-9](-.+)?" regex="true"/> <trust group="org.jetbrains.kotlin" name="kotlin-stdlib-common" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-stdlib-jdk7" version="1.9.[0-9](-.+)?" regex="true"/> <trust group="org.jetbrains.kotlin" name="kotlin-stdlib-jdk7" version="1.9.[0-9](-.+)?" regex="true"/>
@@ -64,6 +61,8 @@
<trust group="org.jetbrains.kotlin" name="kotlin-tooling-metadata" version="1.9.[0-9](-.+)?" regex="true"/> <trust group="org.jetbrains.kotlin" name="kotlin-tooling-metadata" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-util-io" version="1.9.[0-9](-.+)?" regex="true"/> <trust group="org.jetbrains.kotlin" name="kotlin-util-io" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlin-util-klib" version="1.9.[0-9](-.+)?" regex="true"/> <trust group="org.jetbrains.kotlin" name="kotlin-util-klib" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlinx-serialization-compiler-plugin" version="1.9.[0-9](-.+)?" regex="true"/>
<trust group="org.jetbrains.kotlin" name="kotlinx-serialization-compiler-plugin-embeddable" version="1.9.[0-9](-.+)?" regex="true"/>
</trusted-artifacts> </trusted-artifacts>
</configuration> </configuration>
<components> <components>
@@ -19,8 +19,8 @@ package org.jetbrains.kotlin.compilerRunner
import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.diagnostic.Logger
internal class JpsKotlinLogger(private val log: Logger) : KotlinLogger { internal class JpsKotlinLogger(private val log: Logger) : KotlinLogger {
override fun error(msg: String) { override fun error(msg: String, throwable: Throwable?) {
log.error(msg) log.error(msg, throwable)
} }
override fun warn(msg: String) { override fun warn(msg: String) {
@@ -35,6 +35,10 @@ internal class JpsKotlinLogger(private val log: Logger) : KotlinLogger {
log.debug(msg) log.debug(msg)
} }
override fun lifecycle(msg: String) {
log.info(msg)
}
override val isDebugEnabled: Boolean override val isDebugEnabled: Boolean
get() = log.isDebugEnabled get() = log.isDebugEnabled
} }
@@ -42,7 +42,7 @@ import org.jetbrains.kotlin.jps.KotlinJpsBundle
import org.jetbrains.kotlin.jps.incremental.JpsIncrementalCache import org.jetbrains.kotlin.jps.incremental.JpsIncrementalCache
import org.jetbrains.kotlin.jps.incremental.JpsLookupStorageManager import org.jetbrains.kotlin.jps.incremental.JpsLookupStorageManager
import org.jetbrains.kotlin.jps.model.kotlinKind import org.jetbrains.kotlin.jps.model.kotlinKind
import org.jetbrains.kotlin.jps.statistic.KotlinBuilderReportService import org.jetbrains.kotlin.jps.statistic.JpsStatisticsReportService
import org.jetbrains.kotlin.jps.targets.KotlinJvmModuleBuildTarget import org.jetbrains.kotlin.jps.targets.KotlinJvmModuleBuildTarget
import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
@@ -68,7 +68,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
System.getProperty("kotlin.jps.classesToLoadByParent")?.split(',')?.map { it.trim() } ?: emptyList() System.getProperty("kotlin.jps.classesToLoadByParent")?.split(',')?.map { it.trim() } ?: emptyList()
private val classPrefixesToLoadByParentFromRegistry = private val classPrefixesToLoadByParentFromRegistry =
System.getProperty("kotlin.jps.classPrefixesToLoadByParent")?.split(',')?.map { it.trim() } ?: emptyList() System.getProperty("kotlin.jps.classPrefixesToLoadByParent")?.split(',')?.map { it.trim() } ?: emptyList()
private val reportService = KotlinBuilderReportService() private val reportService = JpsStatisticsReportService()
val classesToLoadByParent: ClassCondition val classesToLoadByParent: ClassCondition
get() = ClassCondition { className -> get() = ClassCondition { className ->
@@ -1,32 +0,0 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.jps.statistic
import com.intellij.openapi.diagnostic.Logger
class JpsLoggerAdapter(private val log: Logger) : org.jetbrains.kotlin.util.Logger {
override fun log(message: String) {
log.info(message)
}
override fun warning(message: String) {
log.warn(message)
}
override fun fatal(message: String): Nothing {
log.error(message)
kotlin.error(message)
}
override fun error(message: String, throwable: Throwable?) {
log.error(message, throwable)
}
override fun lifecycle(message: String) {
log.info(message)
}
}
@@ -10,10 +10,9 @@ import org.jetbrains.jps.incremental.CompileContext
import org.jetbrains.kotlin.build.report.FileReportSettings import org.jetbrains.kotlin.build.report.FileReportSettings
import org.jetbrains.kotlin.build.report.HttpReportSettings import org.jetbrains.kotlin.build.report.HttpReportSettings
import org.jetbrains.kotlin.build.report.metrics.* import org.jetbrains.kotlin.build.report.metrics.*
import org.jetbrains.kotlin.build.report.statistic.BuildDataType import org.jetbrains.kotlin.build.report.statistics.*
import org.jetbrains.kotlin.build.report.statistic.CompileStatisticsData import org.jetbrains.kotlin.build.report.statistics.file.FileReportService
import org.jetbrains.kotlin.build.report.statistic.HttpReportServiceImpl import org.jetbrains.kotlin.compilerRunner.JpsKotlinLogger
import org.jetbrains.kotlin.build.report.statistic.file.FileReportService
import java.io.File import java.io.File
import java.util.* import java.util.*
import java.net.InetAddress import java.net.InetAddress
@@ -22,11 +21,11 @@ interface JpsBuilderMetricReporter : BuildMetricsReporter {
fun flush(context: CompileContext): CompileStatisticsData fun flush(context: CompileContext): CompileStatisticsData
} }
//single thread execution private const val jpsBuildTaskName = "JPS build"
class JpsBuilderMetricReporterImpl(private val reporter: BuildMetricsReporterImpl) : JpsBuilderMetricReporter, BuildMetricsReporter by reporter { class JpsBuilderMetricReporterImpl(private val reporter: BuildMetricsReporterImpl) : JpsBuilderMetricReporter, BuildMetricsReporter by reporter {
companion object { companion object {
private val log = Logger.getInstance("#org.jetbrains.kotlin.jps.statistic.KotlinBuilderMetricImpl")
private val hostName: String? = try { private val hostName: String? = try {
InetAddress.getLocalHost().hostName InetAddress.getLocalHost().hostName
} catch (_: Exception) { } catch (_: Exception) {
@@ -38,24 +37,24 @@ class JpsBuilderMetricReporterImpl(private val reporter: BuildMetricsReporterImp
private val uuid = UUID.randomUUID() private val uuid = UUID.randomUUID()
private val startTime = System.currentTimeMillis() private val startTime = System.currentTimeMillis()
override fun flush(context: CompileContext/*, listener: BuildListener*/): CompileStatisticsData { override fun flush(context: CompileContext): CompileStatisticsData {
val buildMetrics = reporter.getMetrics() val buildMetrics = reporter.getMetrics()
return CompileStatisticsData( return CompileStatisticsData(
projectName = context.projectDescriptor.project.name, projectName = context.projectDescriptor.project.name,
label = "JPS build", //TODO label = "JPS build", //TODO will be updated in KT-58026
taskName = "JPS build", taskName = jpsBuildTaskName,
taskResult = "Unknown",//TODO taskResult = "Unknown",//TODO will be updated in KT-58026
startTimeMs = startTime, startTimeMs = startTime,
durationMs = System.currentTimeMillis() - startTime, durationMs = System.currentTimeMillis() - startTime,
tags = emptySet(), tags = emptySet(),
buildUuid = uuid.toString(), buildUuid = uuid.toString(),
changes = emptyList(), //TODO changes = emptyList(), //TODO will be updated in KT-58026
kotlinVersion = "kotlin_version", //TODO kotlinVersion = "kotlin_version", //TODO will be updated in KT-58026
hostName = hostName, hostName = hostName,
finishTime = System.currentTimeMillis(), finishTime = System.currentTimeMillis(),
buildTimesMetrics = buildMetrics.buildTimes.asMapMs(), buildTimesMetrics = buildMetrics.buildTimes.asMapMs(),
performanceMetrics = buildMetrics.buildPerformanceMetrics.asMap(), performanceMetrics = buildMetrics.buildPerformanceMetrics.asMap(),
compilerArguments = emptyList(), //TODO compilerArguments = emptyList(), //TODO will be updated in KT-58026
nonIncrementalAttributes = emptySet(), nonIncrementalAttributes = emptySet(),
type = BuildDataType.JPS_DATA.name, type = BuildDataType.JPS_DATA.name,
fromKotlinPlugin = true, fromKotlinPlugin = true,
@@ -71,14 +70,10 @@ class JpsBuilderMetricReporterImpl(private val reporter: BuildMetricsReporterImp
} }
// TODO test UserDataHolder in CompileContext to store CompileStatisticsData.Build or KotlinBuilderMetric // TODO test UserDataHolder in CompileContext to store CompileStatisticsData.Build or KotlinBuilderMetric
class KotlinBuilderReportService( class JpsStatisticsReportService {
private val fileReportSettings: FileReportSettings?,
private val httpReportSettings: HttpReportSettings? private val fileReportSettings: FileReportSettings? = initFileReportSettings()
) { private val httpReportSettings: HttpReportSettings? = initHttpReportSettings()
constructor() : this(
initFileReportSettings(),
initHttpReportSettings(),
)
companion object { companion object {
private fun initFileReportSettings(): FileReportSettings? { private fun initFileReportSettings(): FileReportSettings? {
@@ -97,8 +92,8 @@ class KotlinBuilderReportService(
private val contextMetrics = HashMap<CompileContext, JpsBuilderMetricReporter>() private val contextMetrics = HashMap<CompileContext, JpsBuilderMetricReporter>()
private val log = Logger.getInstance("#org.jetbrains.kotlin.jps.statistic.KotlinBuilderReportService") private val log = Logger.getInstance("#org.jetbrains.kotlin.jps.statistic.KotlinBuilderReportService")
private val loggerAdapter = JpsLoggerAdapter(log) private val loggerAdapter = JpsKotlinLogger(log)
private val httpService = httpReportSettings?.let { HttpReportServiceImpl(it.url, it.user, it.password) } private val httpService = httpReportSettings?.let { HttpReportService(it.url, it.user, it.password) }
fun buildStarted(context: CompileContext) { fun buildStarted(context: CompileContext) {
if (contextMetrics[context] != null) { if (contextMetrics[context] != null) {
log.error("Service already initialized for context") log.error("Service already initialized for context")
@@ -113,17 +108,13 @@ class KotlinBuilderReportService(
return return
} }
httpService?.sendData(metrics.flush(context), loggerAdapter) val compileStatisticsData = metrics.flush(context)
fileReportSettings?.also { FileReportService(it.buildReportDir, true, loggerAdapter) } httpService?.sendData(compileStatisticsData, loggerAdapter)
} fileReportSettings?.also {
FileReportService(it.buildReportDir, true, loggerAdapter)
fun addMetric(context: CompileContext, metric: BuildTime, value: Long) { .process(listOf(compileStatisticsData),
val metrics = contextMetrics[context] BuildStartParameters(tasks = listOf(jpsBuildTaskName)))
if (metrics == null) {
log.error("Service hasn't initialized for context")
return
} }
metrics.addTimeMetricNs(metric, value)
} }
} }
@@ -38,13 +38,12 @@ class KonanLibrariesResolveSupport(
object : Logger { object : Logger {
private val collector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY) private val collector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
override fun warning(message: String)= collector.report(CompilerMessageSeverity.STRONG_WARNING, message) override fun warning(message: String)= collector.report(CompilerMessageSeverity.STRONG_WARNING, message)
override fun error(message: String, throwable: Throwable?) = collector.report(CompilerMessageSeverity.ERROR, message) override fun error(message: String) = collector.report(CompilerMessageSeverity.ERROR, message)
override fun log(message: String) = collector.report(CompilerMessageSeverity.LOGGING, message) override fun log(message: String) = collector.report(CompilerMessageSeverity.LOGGING, message)
override fun fatal(message: String): Nothing { override fun fatal(message: String): Nothing {
collector.report(CompilerMessageSeverity.ERROR, message) collector.report(CompilerMessageSeverity.ERROR, message)
throw KonanCompilationException() throw KonanCompilationException()
} }
override fun lifecycle(message: String) =collector.report(CompilerMessageSeverity.LOGGING, message)
} }
private val resolver = defaultResolver( private val resolver = defaultResolver(
@@ -88,10 +88,9 @@ fun error(text: String): Nothing {
object KlibToolLogger : Logger { object KlibToolLogger : Logger {
override fun warning(message: String) = org.jetbrains.kotlin.cli.klib.warn(message) override fun warning(message: String) = org.jetbrains.kotlin.cli.klib.warn(message)
override fun error(message: String, throwable: Throwable?) = org.jetbrains.kotlin.cli.klib.warn(message) override fun error(message: String) = org.jetbrains.kotlin.cli.klib.warn(message)
override fun fatal(message: String) = org.jetbrains.kotlin.cli.klib.error(message) override fun fatal(message: String) = org.jetbrains.kotlin.cli.klib.error(message)
override fun log(message: String) = println(message) override fun log(message: String) = println(message)
override fun lifecycle(message: String) = println(message)
} }
val defaultRepository = File(DependencyProcessor.localKonanDir.resolve("klib").absolutePath) val defaultRepository = File(DependencyProcessor.localKonanDir.resolve("klib").absolutePath)
@@ -74,7 +74,7 @@ dependencies {
testImplementation(project(":kotlin-compiler-embeddable")) testImplementation(project(":kotlin-compiler-embeddable"))
testImplementation(commonDependency("org.jetbrains.intellij.deps:jdom")) testImplementation(commonDependency("org.jetbrains.intellij.deps:jdom"))
testImplementation(project(":compiler:cli-common")) testImplementation(project(":compiler:cli-common"))
testImplementation(project(":kotlin-build-statistic")) testImplementation(project(":compiler:build-tools:kotlin-build-statistics"))
// testCompileOnly dependency on non-shaded artifacts is needed for IDE support // testCompileOnly dependency on non-shaded artifacts is needed for IDE support
// testRuntimeOnly on shaded artifact is needed for running tests with shaded compiler // testRuntimeOnly on shaded artifact is needed for running tests with shaded compiler
testCompileOnly(project(":kotlin-gradle-plugin-test-utils-embeddable")) testCompileOnly(project(":kotlin-gradle-plugin-test-utils-embeddable"))
@@ -18,7 +18,7 @@ import io.ktor.server.netty.*
import io.ktor.util.* import io.ktor.util.*
import io.ktor.util.collections.* import io.ktor.util.collections.*
import org.gradle.util.GradleVersion import org.gradle.util.GradleVersion
import org.jetbrains.kotlin.build.report.statistic.* import org.jetbrains.kotlin.build.report.statistics.*
import org.jetbrains.kotlin.gradle.report.BuildReportType import org.jetbrains.kotlin.gradle.report.BuildReportType
import org.jetbrains.kotlin.gradle.testbase.* import org.jetbrains.kotlin.gradle.testbase.*
import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.DisplayName
@@ -52,12 +52,14 @@ dependencies {
commonCompileOnly(intellijCore()) commonCompileOnly(intellijCore())
commonCompileOnly(commonDependency("org.jetbrains.teamcity:serviceMessages")) commonCompileOnly(commonDependency("org.jetbrains.teamcity:serviceMessages"))
commonCompileOnly("com.gradle:gradle-enterprise-gradle-plugin:3.12.4") commonCompileOnly("com.gradle:gradle-enterprise-gradle-plugin:3.12.4")
commonCompileOnly(commonDependency("com.google.code.gson:gson"))
commonCompileOnly(commonDependency("com.google.guava:guava")) commonCompileOnly(commonDependency("com.google.guava:guava"))
commonCompileOnly("de.undercouch:gradle-download-task:4.1.1") commonCompileOnly("de.undercouch:gradle-download-task:4.1.1")
commonCompileOnly("com.github.gundy:semver4j:0.16.4:nodeps") { commonCompileOnly("com.github.gundy:semver4j:0.16.4:nodeps") {
exclude(group = "*") exclude(group = "*")
} }
commonCompileOnly(project(":kotlin-tooling-metadata")) commonCompileOnly(project(":kotlin-tooling-metadata"))
commonCompileOnly(project(":compiler:build-tools:kotlin-build-statistics"))
commonImplementation(project(":kotlin-gradle-plugin-idea")) commonImplementation(project(":kotlin-gradle-plugin-idea"))
@@ -66,7 +68,6 @@ dependencies {
commonImplementation(project(":native:kotlin-klib-commonizer-api")) commonImplementation(project(":native:kotlin-klib-commonizer-api"))
commonImplementation(project(":kotlin-project-model")) commonImplementation(project(":kotlin-project-model"))
commonImplementation(project(":compiler:build-tools:kotlin-build-tools-api")) commonImplementation(project(":compiler:build-tools:kotlin-build-tools-api"))
commonImplementation(project(":kotlin-build-statistic"))
commonRuntimeOnly(project(":kotlin-compiler-embeddable")) commonRuntimeOnly(project(":kotlin-compiler-embeddable"))
commonRuntimeOnly(project(":kotlin-annotation-processing-embeddable")) commonRuntimeOnly(project(":kotlin-annotation-processing-embeddable"))
@@ -111,7 +112,6 @@ dependencies {
testImplementation(commonDependency("junit:junit")) testImplementation(commonDependency("junit:junit"))
testImplementation(project(":kotlin-gradle-statistics")) testImplementation(project(":kotlin-gradle-statistics"))
testImplementation(project(":kotlin-tooling-metadata")) testImplementation(project(":kotlin-tooling-metadata"))
testImplementation(projectTests(":kotlin-build-statistic"))
} }
configurations.commonCompileClasspath.get().exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core") configurations.commonCompileClasspath.get().exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core")
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.logging.* import org.jetbrains.kotlin.gradle.logging.*
import org.jetbrains.kotlin.gradle.plugin.internal.state.TaskExecutionResults import org.jetbrains.kotlin.gradle.plugin.internal.state.TaskExecutionResults
import org.jetbrains.kotlin.gradle.plugin.internal.state.TaskLoggers import org.jetbrains.kotlin.gradle.plugin.internal.state.TaskLoggers
import org.jetbrains.kotlin.build.report.statistic.StatTag import org.jetbrains.kotlin.build.report.statistics.StatTag
import org.jetbrains.kotlin.gradle.report.* import org.jetbrains.kotlin.gradle.report.*
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilerExecutionStrategy import org.jetbrains.kotlin.gradle.tasks.KotlinCompilerExecutionStrategy
import org.jetbrains.kotlin.gradle.tasks.cleanOutputsAndLocalState import org.jetbrains.kotlin.gradle.tasks.cleanOutputsAndLocalState
@@ -13,8 +13,8 @@ internal class GradleKotlinLogger(private val log: Logger) : KotlinLogger {
log.debug(msg) log.debug(msg)
} }
override fun error(msg: String) { override fun error(msg: String, throwable: Throwable?) {
log.error(msg) log.error(msg, throwable)
} }
override fun info(msg: String) { override fun info(msg: String) {
@@ -25,7 +25,7 @@ internal class GradleKotlinLogger(private val log: Logger) : KotlinLogger {
log.warn(msg) log.warn(msg)
} }
fun lifecycle(msg: String) { override fun lifecycle(msg: String) {
log.lifecycle(msg) log.lifecycle(msg)
} }
@@ -13,8 +13,12 @@ internal class SL4JKotlinLogger(private val log: Logger) : KotlinLogger {
log.debug(msg) log.debug(msg)
} }
override fun error(msg: String) { override fun lifecycle(msg: String) {
log.error(msg) log.info(msg)
}
override fun error(msg: String, throwable: Throwable?) {
log.error(msg, throwable)
} }
override fun info(msg: String) { override fun info(msg: String) {
@@ -26,13 +26,12 @@ import org.jetbrains.kotlin.build.report.metrics.BuildMetrics
import org.jetbrains.kotlin.build.report.metrics.BuildMetricsReporter import org.jetbrains.kotlin.build.report.metrics.BuildMetricsReporter
import org.jetbrains.kotlin.build.report.metrics.BuildPerformanceMetric import org.jetbrains.kotlin.build.report.metrics.BuildPerformanceMetric
import org.jetbrains.kotlin.build.report.metrics.BuildTime import org.jetbrains.kotlin.build.report.metrics.BuildTime
import org.jetbrains.kotlin.build.report.statistic.HttpReportService import org.jetbrains.kotlin.build.report.statistics.HttpReportService
import org.jetbrains.kotlin.build.report.statistic.HttpReportServiceImpl
import org.jetbrains.kotlin.gradle.plugin.BuildEventsListenerRegistryHolder import org.jetbrains.kotlin.gradle.plugin.BuildEventsListenerRegistryHolder
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
import org.jetbrains.kotlin.gradle.plugin.internal.state.TaskExecutionResults import org.jetbrains.kotlin.gradle.plugin.internal.state.TaskExecutionResults
import org.jetbrains.kotlin.build.report.statistic.GradleBuildStartParameters import org.jetbrains.kotlin.build.report.statistics.BuildStartParameters
import org.jetbrains.kotlin.build.report.statistic.StatTag import org.jetbrains.kotlin.build.report.statistics.StatTag
import org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatsService import org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatsService
import org.jetbrains.kotlin.gradle.report.BuildReportsService.Companion.getStartParameters import org.jetbrains.kotlin.gradle.report.BuildReportsService.Companion.getStartParameters
import org.jetbrains.kotlin.gradle.report.data.BuildOperationRecord import org.jetbrains.kotlin.gradle.report.data.BuildOperationRecord
@@ -45,6 +44,7 @@ import org.jetbrains.kotlin.statistics.metrics.NumericalMetrics
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ConcurrentLinkedQueue import java.util.concurrent.ConcurrentLinkedQueue
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import java.lang.management.ManagementFactory
internal interface UsesBuildMetricsService : Task { internal interface UsesBuildMetricsService : Task {
@get:Internal @get:Internal
@@ -55,7 +55,7 @@ abstract class BuildMetricsService : BuildService<BuildMetricsService.Parameters
//Part of BuildReportService //Part of BuildReportService
interface Parameters : BuildServiceParameters { interface Parameters : BuildServiceParameters {
val startParameters: Property<GradleBuildStartParameters> val startParameters: Property<BuildStartParameters>
val reportingSettings: Property<ReportingSettings> val reportingSettings: Property<ReportingSettings>
val httpService: Property<HttpReportService> val httpService: Property<HttpReportService>
@@ -204,7 +204,7 @@ abstract class BuildMetricsService : BuildService<BuildMetricsService.Parameters
it.parameters.reportingSettings.set(reportingSettings) it.parameters.reportingSettings.set(reportingSettings)
reportingSettings.httpReportSettings?.let { httpSettings -> reportingSettings.httpReportSettings?.let { httpSettings ->
it.parameters.httpService.set( it.parameters.httpService.set(
HttpReportServiceImpl( HttpReportService(
httpSettings.url, httpSettings.url,
httpSettings.user, httpSettings.user,
httpSettings.password httpSettings.password
@@ -265,6 +265,10 @@ abstract class BuildMetricsService : BuildService<BuildMetricsService.Parameters
if (gradle.startParameter.isBuildCacheEnabled) { if (gradle.startParameter.isBuildCacheEnabled) {
additionalTags.add(StatTag.BUILD_CACHE) additionalTags.add(StatTag.BUILD_CACHE)
} }
val debugConfiguration = "-agentlib:"
if (ManagementFactory.getRuntimeMXBean().inputArguments.firstOrNull { it.startsWith(debugConfiguration) } != null) {
additionalTags.add(StatTag.GRADLE_DEBUG)
}
return additionalTags return additionalTags
} }
} }
@@ -9,18 +9,17 @@ import org.gradle.api.Project
import org.gradle.api.logging.Logging import org.gradle.api.logging.Logging
import org.gradle.tooling.events.task.TaskFinishEvent import org.gradle.tooling.events.task.TaskFinishEvent
import org.jetbrains.kotlin.build.report.metrics.ValueType import org.jetbrains.kotlin.build.report.metrics.ValueType
import org.jetbrains.kotlin.build.report.statistic.HttpReportService import org.jetbrains.kotlin.build.report.statistics.HttpReportService
import org.jetbrains.kotlin.build.report.statistic.file.FileReportService import org.jetbrains.kotlin.build.report.statistics.file.FileReportService
import org.jetbrains.kotlin.build.report.statistic.formatSize import org.jetbrains.kotlin.build.report.statistics.formatSize
import org.jetbrains.kotlin.build.report.statistic.BuildFinishStatisticsData import org.jetbrains.kotlin.build.report.statistics.BuildFinishStatisticsData
import org.jetbrains.kotlin.build.report.statistic.CompileStatisticsData import org.jetbrains.kotlin.build.report.statistics.CompileStatisticsData
import org.jetbrains.kotlin.build.report.statistic.GradleBuildStartParameters import org.jetbrains.kotlin.build.report.statistics.BuildStartParameters
import org.jetbrains.kotlin.build.report.statistic.StatTag import org.jetbrains.kotlin.build.report.statistics.StatTag
import org.jetbrains.kotlin.gradle.report.data.BuildExecutionData import org.jetbrains.kotlin.gradle.report.data.BuildExecutionData
import org.jetbrains.kotlin.gradle.report.data.BuildOperationRecord import org.jetbrains.kotlin.gradle.report.data.BuildOperationRecord
import org.jetbrains.kotlin.utils.addToStdlib.measureTimeMillisWithResult import org.jetbrains.kotlin.utils.addToStdlib.measureTimeMillisWithResult
import java.io.File import java.io.File
import java.lang.management.ManagementFactory
import java.net.InetAddress import java.net.InetAddress
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
@@ -133,11 +132,11 @@ class BuildReportsService {
parameters.httpService?.sendData(buildFinishData, loggerAdapter) parameters.httpService?.sendData(buildFinishData, loggerAdapter)
} }
private fun GradleBuildStartParameters.includeVerboseEnvironment(verboseEnvironment: Boolean): GradleBuildStartParameters { private fun BuildStartParameters.includeVerboseEnvironment(verboseEnvironment: Boolean): BuildStartParameters {
return if (verboseEnvironment) { return if (verboseEnvironment) {
this this
} else { } else {
GradleBuildStartParameters( BuildStartParameters(
tasks = this.tasks, tasks = this.tasks,
excludedTasks = this.excludedTasks, excludedTasks = this.excludedTasks,
currentDir = null, currentDir = null,
@@ -284,10 +283,6 @@ class BuildReportsService {
label?.also { label?.also {
buildScan.buildScan.tag(it) buildScan.buildScan.tag(it)
} }
val debugConfiguration = "-agentlib:"
if (ManagementFactory.getRuntimeMXBean().inputArguments.firstOrNull { it.startsWith(debugConfiguration) } != null) {
buildScan.buildScan.tag(StatTag.GRADLE_DEBUG.readableString)
}
} }
internal fun addCollectedTags(buildScan: BuildScanExtensionHolder) { internal fun addCollectedTags(buildScan: BuildScanExtensionHolder) {
@@ -322,7 +317,7 @@ class BuildReportsService {
private val DATE_FORMATTER = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss") private val DATE_FORMATTER = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")
fun getStartParameters(project: Project) = project.gradle.startParameter.let { fun getStartParameters(project: Project) = project.gradle.startParameter.let {
GradleBuildStartParameters( BuildStartParameters(
tasks = it.taskRequests.flatMap { it.args }, tasks = it.taskRequests.flatMap { it.args },
excludedTasks = it.excludedTaskNames, excludedTasks = it.excludedTaskNames,
currentDir = it.currentDir.path, currentDir = it.currentDir.path,
@@ -352,7 +347,7 @@ enum class TaskExecutionState {
} }
data class BuildReportParameters( data class BuildReportParameters(
val startParameters: GradleBuildStartParameters, val startParameters: BuildStartParameters,
val reportingSettings: ReportingSettings, val reportingSettings: ReportingSettings,
val httpService: HttpReportService?, val httpService: HttpReportService?,
@@ -1,31 +0,0 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.report
import org.gradle.api.logging.Logger
class GradleLoggerAdapter(private val log: Logger) : org.jetbrains.kotlin.util.Logger {
override fun log(message: String) {
log.info(message)
}
override fun warning(message: String) {
log.warn(message)
}
override fun fatal(message: String): Nothing {
log.error(message)
kotlin.error(message)
}
override fun error(message: String, throwable: Throwable?) {
throwable?.let { log.error(message, throwable) } ?: log.error(message)
}
override fun lifecycle(message: String) {
log.lifecycle(message)
}
}
@@ -0,0 +1,34 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.report
import org.gradle.api.logging.Logger
import org.jetbrains.kotlin.compilerRunner.KotlinLogger
class GradleLoggerAdapter(private val log: Logger) : KotlinLogger {
override val isDebugEnabled: Boolean
get() = log.isDebugEnabled
override fun info(msg: String) {
log.info(msg)
}
override fun debug(msg: String) {
log.debug(msg)
}
override fun warn(msg: String) {
log.warn(msg)
}
override fun error(msg: String, throwable: Throwable?) {
throwable?.let { log.error(msg, throwable) } ?: log.error(msg)
}
override fun lifecycle(message: String) {
log.lifecycle(message)
}
}
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.gradle.report
import org.jetbrains.kotlin.build.report.metrics.BuildMetrics import org.jetbrains.kotlin.build.report.metrics.BuildMetrics
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.build.report.statistic.StatTag import org.jetbrains.kotlin.build.report.statistics.StatTag
import org.jetbrains.kotlin.incremental.ChangedFiles import org.jetbrains.kotlin.incremental.ChangedFiles
internal class TaskExecutionResult( internal class TaskExecutionResult(
@@ -6,10 +6,10 @@
package org.jetbrains.kotlin.gradle.report.data package org.jetbrains.kotlin.gradle.report.data
import org.jetbrains.kotlin.build.report.metrics.BuildMetrics import org.jetbrains.kotlin.build.report.metrics.BuildMetrics
import org.jetbrains.kotlin.build.report.statistic.GradleBuildStartParameters import org.jetbrains.kotlin.build.report.statistics.BuildStartParameters
class BuildExecutionData( class BuildExecutionData(
val startParameters: GradleBuildStartParameters, val startParameters: BuildStartParameters,
val failureMessages: List<String?>, val failureMessages: List<String?>,
val buildOperationRecord: Collection<BuildOperationRecord> val buildOperationRecord: Collection<BuildOperationRecord>
) { ) {
@@ -10,8 +10,8 @@ import org.gradle.tooling.events.task.TaskFinishEvent
import org.gradle.tooling.events.task.TaskSkippedResult import org.gradle.tooling.events.task.TaskSkippedResult
import org.gradle.tooling.events.task.TaskSuccessResult import org.gradle.tooling.events.task.TaskSuccessResult
import org.jetbrains.kotlin.build.report.metrics.* import org.jetbrains.kotlin.build.report.metrics.*
import org.jetbrains.kotlin.build.report.statistic.CompileStatisticsData import org.jetbrains.kotlin.build.report.statistics.CompileStatisticsData
import org.jetbrains.kotlin.build.report.statistic.StatTag import org.jetbrains.kotlin.build.report.statistics.StatTag
import org.jetbrains.kotlin.gradle.report.data.BuildOperationRecord import org.jetbrains.kotlin.gradle.report.data.BuildOperationRecord
import org.jetbrains.kotlin.incremental.ChangedFiles import org.jetbrains.kotlin.incremental.ChangedFiles
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@@ -115,9 +115,8 @@ internal fun getAllDependencies(dependency: ResolvedDependencyResult): Set<Resol
internal class GradleLoggerAdapter(private val gradleLogger: Logger) : org.jetbrains.kotlin.util.Logger { internal class GradleLoggerAdapter(private val gradleLogger: Logger) : org.jetbrains.kotlin.util.Logger {
override fun log(message: String) = gradleLogger.info(message) override fun log(message: String) = gradleLogger.info(message)
override fun warning(message: String) = gradleLogger.warn(message) override fun warning(message: String) = gradleLogger.warn(message)
override fun error(message: String, throwable: Throwable?) = kotlin.error(message) override fun error(message: String) = kotlin.error(message)
override fun fatal(message: String): Nothing = kotlin.error(message) override fun fatal(message: String): Nothing = kotlin.error(message)
override fun lifecycle(message: String) = gradleLogger.lifecycle(message)
} }
private fun libraryFilter(artifact: ResolvedArtifactResult): Boolean = artifact.file.absolutePath.endsWith(".klib") private fun libraryFilter(artifact: ResolvedArtifactResult): Boolean = artifact.file.absolutePath.endsWith(".klib")
@@ -11,7 +11,7 @@ import org.gradle.tooling.events.task.TaskFinishEvent
import org.gradle.tooling.events.task.TaskOperationDescriptor import org.gradle.tooling.events.task.TaskOperationDescriptor
import org.gradle.tooling.events.task.TaskOperationResult import org.gradle.tooling.events.task.TaskOperationResult
import org.jetbrains.kotlin.build.report.metrics.* import org.jetbrains.kotlin.build.report.metrics.*
import org.jetbrains.kotlin.build.report.statistic.StatTag import org.jetbrains.kotlin.build.report.statistics.StatTag
import org.jetbrains.kotlin.gradle.report.TaskRecord import org.jetbrains.kotlin.gradle.report.TaskRecord
import org.jetbrains.kotlin.gradle.report.prepareData import org.jetbrains.kotlin.gradle.report.prepareData
import org.junit.Ignore import org.junit.Ignore
@@ -20,15 +20,13 @@ internal class CliLoggerAdapter(
override fun warning(message: String) = printlnIndented("Warning: $message", *CommonizerLogLevel.values()) override fun warning(message: String) = printlnIndented("Warning: $message", *CommonizerLogLevel.values())
override fun error(message: String, throwable: Throwable?) = fatal(message) override fun error(message: String) = fatal(message)
override fun fatal(message: String): Nothing { override fun fatal(message: String): Nothing {
printlnIndented("Error: $message\n", *CommonizerLogLevel.values()) printlnIndented("Error: $message\n", *CommonizerLogLevel.values())
exitProcess(1) exitProcess(1)
} }
override fun lifecycle(message: String) = log(message)
private fun printlnIndented(text: String, vararg levels: CommonizerLogLevel) { private fun printlnIndented(text: String, vararg levels: CommonizerLogLevel) {
if (level in levels) { if (level in levels) {
if (indent.isEmpty()) println(text) if (indent.isEmpty()) println(text)
+1 -2
View File
@@ -205,7 +205,7 @@ include ":kotlin-imports-dumper-compiler-plugin",
":kotlin-gradle-plugin-test-utils-embeddable", ":kotlin-gradle-plugin-test-utils-embeddable",
":kotlin-gradle-plugin-integration-tests", ":kotlin-gradle-plugin-integration-tests",
":kotlin-gradle-plugins-bom", ":kotlin-gradle-plugins-bom",
":kotlin-build-statistic", ":compiler:build-tools:kotlin-build-statistics",
":gradle:android-test-fixes", ":gradle:android-test-fixes",
":gradle:gradle-warnings-detector", ":gradle:gradle-warnings-detector",
":gradle:kotlin-compiler-args-properties", ":gradle:kotlin-compiler-args-properties",
@@ -808,7 +808,6 @@ project(':kotlin-scripting-ide-services-unshaded').projectDir = "$rootDir/plugin
project(':kotlin-scripting-ide-services-test').projectDir = "$rootDir/plugins/scripting/scripting-ide-services-test" as File project(':kotlin-scripting-ide-services-test').projectDir = "$rootDir/plugins/scripting/scripting-ide-services-test" as File
project(':kotlin-scripting-ide-services').projectDir = "$rootDir/plugins/scripting/scripting-ide-services-embeddable" as File project(':kotlin-scripting-ide-services').projectDir = "$rootDir/plugins/scripting/scripting-ide-services-embeddable" as File
project(':kotlin-scripting-ide-common').projectDir = "$rootDir/plugins/scripting/scripting-ide-common" as File project(':kotlin-scripting-ide-common').projectDir = "$rootDir/plugins/scripting/scripting-ide-common" as File
project(':kotlin-build-statistic').projectDir ="$rootDir/kotlin-build-statistic" as File
// Uncomment to use locally built protobuf-relocated // Uncomment to use locally built protobuf-relocated
// includeBuild("dependencies/protobuf") // includeBuild("dependencies/protobuf")