-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finalize BuildFusService parameters to avoid CME
#KTI-1611 (cherry picked from commit aa0aa60)
- Loading branch information
Showing
8 changed files
with
91 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...lin/org/jetbrains/kotlin/gradle/plugin/statistics/FinalizeConfigurationFusMetricAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2010-2024 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.plugin.statistics | ||
|
||
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle | ||
import org.jetbrains.kotlin.gradle.plugin.KotlinProjectSetupCoroutine | ||
import org.jetbrains.kotlin.gradle.plugin.await | ||
|
||
|
||
internal val FinalizeConfigurationFusMetricAction = KotlinProjectSetupCoroutine { | ||
KotlinPluginLifecycle.Stage.ReadyForExecution.await() | ||
|
||
val projectConfigurationService = | ||
project.gradle.sharedServices.registrations.findByName(ProjectConfigurationFusService.getServiceName(project))?.also { | ||
val parameters = it.parameters as ProjectConfigurationFusService.Parameters | ||
parameters.configurationMetrics.finalizeValue() | ||
} | ||
|
||
project.gradle.sharedServices.registrations.findByName(BuildFusService.serviceName)?.also { | ||
val parameters = it.parameters as BuildFusService.Parameters | ||
parameters.generalConfigurationMetrics.finalizeValue() | ||
projectConfigurationService?.service?.orNull?.also { | ||
parameters.configurationMetrics.add((it.parameters as ProjectConfigurationFusService.Parameters).configurationMetrics) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...on/kotlin/org/jetbrains/kotlin/gradle/plugin/statistics/ProjectConfigurationFusService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2010-2024 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.plugin.statistics | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.provider.Property | ||
import org.gradle.api.provider.Provider | ||
import org.gradle.api.services.BuildService | ||
import org.gradle.api.services.BuildServiceParameters | ||
|
||
abstract class ProjectConfigurationFusService : BuildService<ProjectConfigurationFusService.Parameters>, AutoCloseable { | ||
interface Parameters : BuildServiceParameters { | ||
val configurationMetrics: Property<MetricContainer> | ||
} | ||
|
||
companion object { | ||
fun getServiceName(project: Project): String = | ||
"${project.path}_${ProjectConfigurationFusService::class.simpleName}_${ProjectConfigurationFusService::class.java.classLoader.hashCode()}" | ||
|
||
//register a new service for every project to collect configuration metrics | ||
fun registerIfAbsent(project: Project): Provider<ProjectConfigurationFusService> { | ||
return project.gradle.sharedServices.registerIfAbsent( | ||
getServiceName(project), | ||
ProjectConfigurationFusService::class.java | ||
) { spec -> | ||
spec.parameters.configurationMetrics.set(project.provider { | ||
KotlinProjectConfigurationMetrics.collectMetrics(project) | ||
}) | ||
} | ||
} | ||
} | ||
|
||
override fun close() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters