Add proper kotlin version into http reports
This commit is contained in:
+4
-4
@@ -49,7 +49,7 @@ internal abstract class KotlinGradleBuildServices : BuildService<KotlinGradleBui
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun registerIfAbsent(project: Project): Provider<KotlinGradleBuildServices> = project.gradle.sharedServices.registerIfAbsent(
|
||||
fun registerIfAbsent(project: Project, kotlinVersion: String): Provider<KotlinGradleBuildServices> = project.gradle.sharedServices.registerIfAbsent(
|
||||
"kotlin-build-service-${KotlinGradleBuildServices::class.java.canonicalName}_${KotlinGradleBuildServices::class.java.classLoader.hashCode()}",
|
||||
KotlinGradleBuildServices::class.java
|
||||
) { service ->
|
||||
@@ -57,10 +57,10 @@ internal abstract class KotlinGradleBuildServices : BuildService<KotlinGradleBui
|
||||
service.parameters.buildDir = project.rootProject.buildDir
|
||||
|
||||
val reportingSettings = reportingSettings(project.rootProject)
|
||||
addListeners(project, reportingSettings)
|
||||
addListeners(project, reportingSettings, kotlinVersion)
|
||||
}
|
||||
|
||||
fun addListeners(project: Project, reportingSettings: ReportingSettings) {
|
||||
fun addListeners(project: Project, reportingSettings: ReportingSettings, kotlinVersion: String) {
|
||||
val listeners = project.rootProject.objects.listProperty(ReportStatistics::class.java)
|
||||
.value(listOf<ReportStatistics>())
|
||||
|
||||
@@ -73,7 +73,7 @@ internal abstract class KotlinGradleBuildServices : BuildService<KotlinGradleBui
|
||||
|
||||
if (listeners.get().isNotEmpty()) {
|
||||
val listenerRegistryHolder = BuildEventsListenerRegistryHolder.getInstance(project)
|
||||
val statListener = KotlinBuildStatListener(project.rootProject.name, reportingSettings.buildReportLabel, listeners.get())
|
||||
val statListener = KotlinBuildStatListener(project.rootProject.name, reportingSettings.buildReportLabel, kotlinVersion, listeners.get())
|
||||
listenerRegistryHolder.listenerRegistry.onTaskCompletion(project.provider { statListener })
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -90,7 +90,7 @@ abstract class KotlinBasePluginWrapper : Plugin<Project> {
|
||||
}
|
||||
project.registerCommonizerClasspathConfigurationIfNecessary()
|
||||
|
||||
KotlinGradleBuildServices.registerIfAbsent(project).get()
|
||||
KotlinGradleBuildServices.registerIfAbsent(project, kotlinPluginVersion).get()
|
||||
|
||||
KotlinGradleBuildServices.detectKotlinPluginLoadedInMultipleProjects(project, kotlinPluginVersion)
|
||||
|
||||
@@ -98,7 +98,7 @@ abstract class KotlinBasePluginWrapper : Plugin<Project> {
|
||||
|
||||
buildMetricReporter?.also { BuildEventsListenerRegistryHolder.getInstance(project).listenerRegistry.onTaskCompletion(it) }
|
||||
|
||||
HttpReportService.registerIfAbsent(project)
|
||||
HttpReportService.registerIfAbsent(project, kotlinPluginVersion)
|
||||
?.also { BuildEventsListenerRegistryHolder.getInstance(project).listenerRegistry.onTaskCompletion(it) }
|
||||
|
||||
project.tasks.withType(AbstractKotlinCompile::class.java).configureEach {
|
||||
|
||||
+14
-7
@@ -34,6 +34,7 @@ enum class TaskExecutionState {
|
||||
class KotlinBuildStatListener(
|
||||
val projectName: String,
|
||||
val label: String?,
|
||||
val kotlinVersion: String,
|
||||
val reportStatistics: List<ReportStatistics>
|
||||
) : OperationCompletionListener, AutoCloseable {
|
||||
|
||||
@@ -52,7 +53,13 @@ class KotlinBuildStatListener(
|
||||
return taskPath.contains("Kotlin") && (TaskExecutionResults[taskPath] != null)
|
||||
}
|
||||
|
||||
internal fun prepareData(event: TaskFinishEvent, projectName:String, uuid: String, label: String?): CompileStatData? {
|
||||
internal fun prepareData(
|
||||
event: TaskFinishEvent,
|
||||
projectName: String,
|
||||
uuid: String,
|
||||
label: String?,
|
||||
kotlinVersion: String
|
||||
): CompileStatData? {
|
||||
val result = event.result
|
||||
val taskPath = event.descriptor.taskPath
|
||||
val durationMs = result.endTime - result.startTime
|
||||
@@ -63,10 +70,10 @@ class KotlinBuildStatListener(
|
||||
else -> TaskExecutionState.SUCCESS
|
||||
}
|
||||
|
||||
is TaskSkippedResult -> TaskExecutionState.SKIPPED
|
||||
is TaskFailureResult -> TaskExecutionState.FAILED
|
||||
else -> TaskExecutionState.UNKNOWN
|
||||
}
|
||||
is TaskSkippedResult -> TaskExecutionState.SKIPPED
|
||||
is TaskFailureResult -> TaskExecutionState.FAILED
|
||||
else -> TaskExecutionState.UNKNOWN
|
||||
}
|
||||
|
||||
if (!availableForStat(taskPath)) {
|
||||
return null
|
||||
@@ -87,7 +94,7 @@ class KotlinBuildStatListener(
|
||||
buildTimesMs = buildTimesMs, perfData = perfData, projectName = projectName, taskName = taskPath, changes = changes,
|
||||
tags = taskExecutionResult?.taskInfo?.properties?.map { it.name } ?: emptyList(),
|
||||
nonIncrementalAttributes = taskExecutionResult?.buildMetrics?.buildAttributes?.asMap() ?: emptyMap(),
|
||||
hostName = hostName, kotlinVersion = "1.6", buildUuid = uuid, timeInMillis = System.currentTimeMillis()
|
||||
hostName = hostName, kotlinVersion = kotlinVersion, buildUuid = uuid, timeInMillis = System.currentTimeMillis()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -96,7 +103,7 @@ class KotlinBuildStatListener(
|
||||
override fun onFinish(event: FinishEvent?) {
|
||||
if (event is TaskFinishEvent) {
|
||||
val (collectDataDuration, compileStatData) = measureTimeMillisWithResult {
|
||||
prepareData(event, projectName, buildUuid, label)
|
||||
prepareData(event, projectName, buildUuid, label, kotlinVersion)
|
||||
}
|
||||
log.debug("Collect data takes $collectDataDuration: $compileStatData")
|
||||
|
||||
|
||||
+4
-2
@@ -33,13 +33,14 @@ abstract class HttpReportService : BuildService<HttpReportService.Parameters>,
|
||||
var uuid: String
|
||||
var projectName: String
|
||||
var httpSettings: HttpReportSettings
|
||||
var kotlinVersion: String
|
||||
}
|
||||
|
||||
private val log = Logging.getLogger(this.javaClass)
|
||||
|
||||
override fun onFinish(event: FinishEvent?) {
|
||||
if (event is TaskFinishEvent) {
|
||||
val data = prepareData(event, parameters.projectName, parameters.uuid, parameters.label)
|
||||
val data = prepareData(event, parameters.projectName, parameters.uuid, parameters.label, parameters.kotlinVersion)
|
||||
data?.also { executorService.submit { report(data) } }
|
||||
}
|
||||
}
|
||||
@@ -50,7 +51,7 @@ abstract class HttpReportService : BuildService<HttpReportService.Parameters>,
|
||||
|
||||
companion object {
|
||||
|
||||
fun registerIfAbsent(project: Project): Provider<HttpReportService>? {
|
||||
fun registerIfAbsent(project: Project, kotlinVersion: String): Provider<HttpReportService>? {
|
||||
val rootProject = project.gradle.rootProject
|
||||
val reportingSettings = reportingSettings(rootProject)
|
||||
|
||||
@@ -63,6 +64,7 @@ abstract class HttpReportService : BuildService<HttpReportService.Parameters>,
|
||||
it.parameters.projectName = rootProject.name
|
||||
it.parameters.uuid = UUID.randomUUID().toString()
|
||||
it.parameters.httpSettings = httpSettings
|
||||
it.parameters.kotlinVersion = kotlinVersion
|
||||
}!!
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user