Add JSON output type for build reports
#KT-65792 Fixed
This commit is contained in:
committed by
Space Team
parent
f493df42a9
commit
5885514c3d
+4
@@ -110,6 +110,9 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
val buildReportMetrics: Boolean
|
||||
get() = booleanProperty("kotlin.build.report.metrics") ?: false
|
||||
|
||||
val buildReportJsonDir: File?
|
||||
get() = property(PropertyNames.KOTLIN_BUILD_REPORT_JSON_DIR).orNull?.let { File(it) }
|
||||
|
||||
val buildReportVerbose: Boolean
|
||||
get() = booleanProperty("kotlin.build.report.verbose") ?: false
|
||||
|
||||
@@ -643,6 +646,7 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
val KOTLIN_JS_KARMA_BROWSERS = property("kotlin.js.browser.karma.browsers")
|
||||
val KOTLIN_BUILD_REPORT_SINGLE_FILE = property("kotlin.build.report.single_file")
|
||||
val KOTLIN_BUILD_REPORT_HTTP_URL = property("kotlin.build.report.http.url")
|
||||
val KOTLIN_BUILD_REPORT_JSON_DIR = property("kotlin.build.report.json.directory")
|
||||
val KOTLIN_OPTIONS_SUPPRESS_FREEARGS_MODIFICATION_WARNING = property("kotlin.options.suppressFreeCompilerArgsModificationWarning")
|
||||
val KOTLIN_NATIVE_USE_XCODE_MESSAGE_STYLE = property("kotlin.native.useXcodeMessageStyle")
|
||||
val KOTLIN_INCREMENTAL_USE_CLASSPATH_SNAPSHOT = property("kotlin.incremental.useClasspathSnapshot")
|
||||
|
||||
+2
-4
@@ -7,13 +7,11 @@ package org.jetbrains.kotlin.gradle.plugin.statistics
|
||||
|
||||
import org.jetbrains.kotlin.build.report.metrics.GradleBuildPerformanceMetric
|
||||
import org.jetbrains.kotlin.build.report.metrics.GradleBuildTime
|
||||
import org.jetbrains.kotlin.build.report.statistics.file.FileReportService
|
||||
import org.jetbrains.kotlin.buildtools.api.KotlinLogger
|
||||
import org.jetbrains.kotlin.build.report.statistics.file.ReadableFileReportService
|
||||
import java.io.File
|
||||
|
||||
class GradleFileReportService(
|
||||
buildReportDir: File,
|
||||
projectName: String,
|
||||
printMetrics: Boolean,
|
||||
logger: KotlinLogger,
|
||||
) : FileReportService<GradleBuildTime, GradleBuildPerformanceMetric>(buildReportDir, projectName, printMetrics, logger) {}
|
||||
) : ReadableFileReportService<GradleBuildTime, GradleBuildPerformanceMetric>(buildReportDir, projectName, printMetrics)
|
||||
+1
@@ -39,6 +39,7 @@ internal fun collectGeneralConfigurationTimeMetrics(
|
||||
BuildReportType.HTTP -> configurationTimeMetrics.put(BooleanMetrics.HTTP_BUILD_REPORT, true)
|
||||
BuildReportType.SINGLE_FILE -> configurationTimeMetrics.put(BooleanMetrics.SINGLE_FILE_BUILD_REPORT, true)
|
||||
BuildReportType.TRY_NEXT_CONSOLE -> {}//ignore
|
||||
BuildReportType.JSON -> configurationTimeMetrics.put(BooleanMetrics.JSON_BUILD_REPORT, true)
|
||||
}
|
||||
}
|
||||
configurationTimeMetrics.put(StringMetrics.PROJECT_PATH, gradle.rootProject.projectDir.absolutePath)
|
||||
|
||||
+2
-1
@@ -13,9 +13,10 @@ enum class BuildReportType : Serializable {
|
||||
BUILD_SCAN,
|
||||
SINGLE_FILE,
|
||||
TRY_NEXT_CONSOLE,
|
||||
JSON,
|
||||
;
|
||||
|
||||
companion object {
|
||||
const val serialVersionUID: Long = 2L
|
||||
const val serialVersionUID: Long = 3L
|
||||
}
|
||||
}
|
||||
+12
-9
@@ -9,11 +9,8 @@ import org.gradle.api.Project
|
||||
import org.gradle.api.logging.Logging
|
||||
import org.gradle.tooling.events.task.TaskFinishEvent
|
||||
import org.jetbrains.kotlin.build.report.metrics.ValueType
|
||||
import org.jetbrains.kotlin.build.report.statistics.HttpReportService
|
||||
import org.jetbrains.kotlin.build.report.statistics.formatSize
|
||||
import org.jetbrains.kotlin.build.report.statistics.BuildFinishStatisticsData
|
||||
import org.jetbrains.kotlin.build.report.statistics.BuildStartParameters
|
||||
import org.jetbrains.kotlin.build.report.statistics.StatTag
|
||||
import org.jetbrains.kotlin.build.report.statistics.*
|
||||
import org.jetbrains.kotlin.build.report.statistics.file.ReadableFileReportData
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
||||
import org.jetbrains.kotlin.gradle.plugin.statistics.GradleFileReportService
|
||||
import org.jetbrains.kotlin.gradle.report.data.BuildExecutionData
|
||||
@@ -69,11 +66,13 @@ class BuildReportsService {
|
||||
it.buildReportDir,
|
||||
parameters.projectName,
|
||||
it.includeMetricsInReport,
|
||||
loggerAdapter
|
||||
).process(
|
||||
transformOperationRecordsToCompileStatisticsData(buildOperationRecords, parameters, onlyKotlinTask = false),
|
||||
parameters.startParameters,
|
||||
failureMessages.filter { it.isNotEmpty() },
|
||||
ReadableFileReportData(
|
||||
transformOperationRecordsToCompileStatisticsData(buildOperationRecords, parameters, onlyKotlinTask = false),
|
||||
parameters.startParameters,
|
||||
failureMessages.filter { it.isNotEmpty() },
|
||||
),
|
||||
loggerAdapter
|
||||
)
|
||||
}
|
||||
|
||||
@@ -85,6 +84,10 @@ class BuildReportsService {
|
||||
reportTryNextToConsole(buildData)
|
||||
}
|
||||
|
||||
reportingSettings.jsonOutputDir?.also {
|
||||
JsonReportService(it, parameters.projectName).process(buildData, loggerAdapter)
|
||||
}
|
||||
|
||||
//It's expected that bad internet connection can cause a significant delay for big project
|
||||
executorService.shutdown()
|
||||
}
|
||||
|
||||
+1
@@ -18,6 +18,7 @@ data class ReportingSettings(
|
||||
val httpReportSettings: HttpReportSettings? = null,
|
||||
val buildScanReportSettings: BuildScanSettings? = null,
|
||||
val singleOutputFile: File? = null,
|
||||
val jsonOutputDir: File? = null,
|
||||
val experimentalTryNextConsoleOutput: Boolean = false,
|
||||
val includeCompilerArguments: Boolean = false,
|
||||
) : Serializable {
|
||||
|
||||
+7
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.build.report.metrics.GradleBuildTime
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_BUILD_REPORT_SINGLE_FILE
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_BUILD_REPORT_HTTP_URL
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.PropertyNames.KOTLIN_BUILD_REPORT_JSON_DIR
|
||||
import org.jetbrains.kotlin.gradle.plugin.internal.isProjectIsolationEnabled
|
||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toUpperCaseAsciiOnly
|
||||
|
||||
@@ -78,6 +79,11 @@ internal fun reportingSettings(project: Project): ReportingSettings {
|
||||
?: throw IllegalStateException("Can't configure single file report: '$KOTLIN_BUILD_REPORT_SINGLE_FILE' property is mandatory")
|
||||
} else null
|
||||
|
||||
val jsonReportDir = if (buildReportOutputTypes.contains(BuildReportType.JSON)) {
|
||||
properties.buildReportJsonDir
|
||||
?: throw IllegalStateException("Can't configure json report: '$KOTLIN_BUILD_REPORT_JSON_DIR' property is mandatory")
|
||||
} else null
|
||||
|
||||
//temporary solution. support old property
|
||||
@Suppress("DEPRECATION")
|
||||
val oldSingleBuildMetric = properties.singleBuildMetricsFile?.also { buildReportOutputTypes.add(BuildReportType.SINGLE_FILE) }
|
||||
@@ -90,6 +96,7 @@ internal fun reportingSettings(project: Project): ReportingSettings {
|
||||
buildScanReportSettings = buildScanSettings,
|
||||
buildReportOutputs = buildReportOutputTypes,
|
||||
singleOutputFile = singleOutputFile ?: oldSingleBuildMetric,
|
||||
jsonOutputDir = jsonReportDir,
|
||||
includeCompilerArguments = properties.buildReportIncludeCompilerArguments,
|
||||
experimentalTryNextConsoleOutput = experimentalTryNextEnabled
|
||||
)
|
||||
|
||||
+5
-6
@@ -10,14 +10,13 @@ import org.jetbrains.kotlin.build.report.metrics.GradleBuildPerformanceMetric
|
||||
import org.jetbrains.kotlin.build.report.metrics.GradleBuildTime
|
||||
import org.jetbrains.kotlin.build.report.statistics.BuildStartParameters
|
||||
|
||||
class BuildExecutionData(
|
||||
data class BuildExecutionData(
|
||||
val startParameters: BuildStartParameters,
|
||||
val failureMessages: List<String?>,
|
||||
val buildOperationRecord: Collection<BuildOperationRecord>
|
||||
val buildOperationRecord: Collection<BuildOperationRecord>,
|
||||
) {
|
||||
val aggregatedMetrics by lazy {
|
||||
BuildMetrics<GradleBuildTime, GradleBuildPerformanceMetric>().also { acc ->
|
||||
buildOperationRecord.forEach { acc.addAll(it.buildMetrics) }
|
||||
}
|
||||
val aggregatedMetrics = BuildMetrics<GradleBuildTime, GradleBuildPerformanceMetric>().also { acc ->
|
||||
buildOperationRecord.forEach { acc.addAll(it.buildMetrics) }
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user