Added FUS statistics for applied plugins: kotlin-js, cocoapod plugin
#KT-59324 In Progress Merge-request: KT-MR-11360 Merged-by: Dmitrii Krasnov <Dmitrii.Krasnov@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
3ff21db77f
commit
e7c589a573
+41
-26
@@ -6,10 +6,9 @@
|
|||||||
package org.jetbrains.kotlin.gradle
|
package org.jetbrains.kotlin.gradle
|
||||||
|
|
||||||
import org.gradle.util.GradleVersion
|
import org.gradle.util.GradleVersion
|
||||||
import org.jetbrains.kotlin.gradle.testbase.GradleTest
|
|
||||||
import org.junit.jupiter.api.DisplayName
|
|
||||||
import org.jetbrains.kotlin.gradle.testbase.*
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
import org.jetbrains.kotlin.gradle.util.replaceText
|
import org.jetbrains.kotlin.gradle.util.replaceText
|
||||||
|
import org.junit.jupiter.api.DisplayName
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
|
||||||
@DisplayName("FUS statistic")
|
@DisplayName("FUS statistic")
|
||||||
@@ -25,6 +24,9 @@ class FusStatisticsIT : KGPDaemonsBaseTest() {
|
|||||||
"KOTLIN_COMPILER_VERSION",
|
"KOTLIN_COMPILER_VERSION",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val GradleProject.fusStatisticsPath: Path
|
||||||
|
get() = projectPath.getSingleFileInDir("kotlin-profile")
|
||||||
|
|
||||||
@DisplayName("for dokka")
|
@DisplayName("for dokka")
|
||||||
@GradleTest
|
@GradleTest
|
||||||
@GradleTestVersions(
|
@GradleTestVersions(
|
||||||
@@ -46,30 +48,32 @@ class FusStatisticsIT : KGPDaemonsBaseTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun TestProject.applyDokka() {
|
@DisplayName("Verify that the metric for applying the Cocoapods plugin is being collected")
|
||||||
buildGradle.replaceText(
|
@GradleTest
|
||||||
"plugins {",
|
fun testMetricCollectingOfApplyingCocoapodsPlugin(gradleVersion: GradleVersion) {
|
||||||
"""
|
project("native-cocoapods-template", gradleVersion) {
|
||||||
plugins {
|
build("assemble", "-Pkotlin.session.logger.root.path=$projectPath") {
|
||||||
id("org.jetbrains.dokka") version "1.8.10"
|
assertFileContains(fusStatisticsPath, "COCOAPODS_PLUGIN_ENABLED=true")
|
||||||
""".trimIndent()
|
}
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val GradleProject.fusStatisticsPath: Path
|
@DisplayName("Verify that the metric for applying the Kotlin JS plugin is being collected")
|
||||||
get() = projectPath.getSingleFileInDir("kotlin-profile")
|
|
||||||
|
|
||||||
@DisplayName("general fields")
|
|
||||||
@GradleTest
|
@GradleTest
|
||||||
@GradleTestVersions(
|
fun testMetricCollectingOfApplyingKotlinJsPlugin(gradleVersion: GradleVersion) {
|
||||||
additionalVersions = [TestVersions.Gradle.G_7_6, TestVersions.Gradle.G_8_0],
|
project("simple-js-library", gradleVersion) {
|
||||||
)
|
build("assemble", "-Pkotlin.session.logger.root.path=$projectPath") {
|
||||||
fun testFusStatistics(gradleVersion: GradleVersion) {
|
assertFileContains(fusStatisticsPath, "KOTLIN_JS_PLUGIN_ENABLED=true")
|
||||||
project(
|
}
|
||||||
"simpleProject",
|
}
|
||||||
gradleVersion,
|
}
|
||||||
) {
|
|
||||||
build("compileKotlin", "-Pkotlin.session.logger.root.path=$projectPath") {
|
|
||||||
|
@DisplayName("Ensure that the metric are not collected if plugins were not applied to simple project")
|
||||||
|
@GradleTest
|
||||||
|
fun testAppliedPluginsMetricsAreNotCollectedInSimpleProject(gradleVersion: GradleVersion) {
|
||||||
|
project("simpleProject", gradleVersion) {
|
||||||
|
build("assemble", "-Pkotlin.session.logger.root.path=$projectPath") {
|
||||||
val fusStatisticsPath = fusStatisticsPath
|
val fusStatisticsPath = fusStatisticsPath
|
||||||
assertFileContains(
|
assertFileContains(
|
||||||
fusStatisticsPath,
|
fusStatisticsPath,
|
||||||
@@ -77,9 +81,9 @@ class FusStatisticsIT : KGPDaemonsBaseTest() {
|
|||||||
)
|
)
|
||||||
assertFileDoesNotContain(
|
assertFileDoesNotContain(
|
||||||
fusStatisticsPath,
|
fusStatisticsPath,
|
||||||
"ENABLED_DOKKA",
|
"ENABLED_DOKKA_HTML"
|
||||||
"ENABLED_DOKKA_HTML",
|
|
||||||
) // asserts that we do not put DOKKA metrics everywhere just in case
|
) // asserts that we do not put DOKKA metrics everywhere just in case
|
||||||
|
assertFileDoesNotContain(fusStatisticsPath, "KOTLIN_JS_PLUGIN_ENABLED")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,7 +170,7 @@ class FusStatisticsIT : KGPDaemonsBaseTest() {
|
|||||||
@GradleTest
|
@GradleTest
|
||||||
@GradleTestVersions(
|
@GradleTestVersions(
|
||||||
additionalVersions = [TestVersions.Gradle.G_7_6, TestVersions.Gradle.G_8_0],
|
additionalVersions = [TestVersions.Gradle.G_7_6, TestVersions.Gradle.G_8_0],
|
||||||
)
|
)
|
||||||
fun testFusStatisticsWithConfigurationCache(gradleVersion: GradleVersion) {
|
fun testFusStatisticsWithConfigurationCache(gradleVersion: GradleVersion) {
|
||||||
project(
|
project(
|
||||||
"simpleProject",
|
"simpleProject",
|
||||||
@@ -188,4 +192,15 @@ class FusStatisticsIT : KGPDaemonsBaseTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun TestProject.applyDokka() {
|
||||||
|
buildGradle.replaceText(
|
||||||
|
"plugins {",
|
||||||
|
"""
|
||||||
|
plugins {
|
||||||
|
id("org.jetbrains.dokka") version "1.8.10"
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+14
-5
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.gradle.plugin.statistics
|
|||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.artifacts.DependencySet
|
import org.gradle.api.artifacts.DependencySet
|
||||||
import org.gradle.api.logging.Logging
|
import org.gradle.api.logging.Logging
|
||||||
import org.jetbrains.kotlin.gradle.plugin.internal.isProjectIsolationEnabled
|
import org.jetbrains.kotlin.gradle.plugin.statistics.plugins.ObservablePlugins
|
||||||
import org.jetbrains.kotlin.gradle.utils.*
|
import org.jetbrains.kotlin.gradle.utils.*
|
||||||
import org.jetbrains.kotlin.statistics.BuildSessionLogger
|
import org.jetbrains.kotlin.statistics.BuildSessionLogger
|
||||||
import org.jetbrains.kotlin.statistics.metrics.BooleanMetrics
|
import org.jetbrains.kotlin.statistics.metrics.BooleanMetrics
|
||||||
@@ -23,7 +23,6 @@ import kotlin.system.measureTimeMillis
|
|||||||
|
|
||||||
class KotlinBuildStatHandler {
|
class KotlinBuildStatHandler {
|
||||||
companion object {
|
companion object {
|
||||||
const val DOKKA_PLUGIN = "org.jetbrains.dokka"
|
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
internal fun getLogger() = Logging.getLogger(KotlinBuildStatHandler::class.java)
|
internal fun getLogger() = Logging.getLogger(KotlinBuildStatHandler::class.java)
|
||||||
@@ -104,9 +103,8 @@ class KotlinBuildStatHandler {
|
|||||||
|
|
||||||
val statisticOverhead = measureTimeMillis {
|
val statisticOverhead = measureTimeMillis {
|
||||||
gradle.allprojects { project ->
|
gradle.allprojects { project ->
|
||||||
project.plugins.findPlugin(DOKKA_PLUGIN)?.also {
|
collectAppliedPluginsStatistics(project, configurationTimeMetrics)
|
||||||
configurationTimeMetrics.put(BooleanMetrics.ENABLED_DOKKA, true)
|
|
||||||
}
|
|
||||||
for (configuration in project.configurations) {
|
for (configuration in project.configurations) {
|
||||||
try {
|
try {
|
||||||
val configurationName = configuration.name
|
val configurationName = configuration.name
|
||||||
@@ -176,6 +174,17 @@ class KotlinBuildStatHandler {
|
|||||||
return configurationTimeMetrics
|
return configurationTimeMetrics
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun collectAppliedPluginsStatistics(
|
||||||
|
project: Project,
|
||||||
|
configurationTimeMetrics: MetricContainer,
|
||||||
|
) {
|
||||||
|
for (plugin in ObservablePlugins.values()) {
|
||||||
|
project.plugins.withId(plugin.title) {
|
||||||
|
configurationTimeMetrics.put(plugin.metric, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun reportLibrariesVersions(configurationTimeMetrics: MetricContainer, dependencies: DependencySet?) {
|
private fun reportLibrariesVersions(configurationTimeMetrics: MetricContainer, dependencies: DependencySet?) {
|
||||||
dependencies?.forEach { dependency ->
|
dependencies?.forEach { dependency ->
|
||||||
when {
|
when {
|
||||||
|
|||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* 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.plugin.statistics.plugins
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.statistics.metrics.BooleanMetrics
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an enumeration of plugins that can be observed during statistics collecting.
|
||||||
|
*
|
||||||
|
* Each plugin is associated with a title and a boolean statistic metric.
|
||||||
|
*
|
||||||
|
* @property title The title of the plugin.
|
||||||
|
* @property metric The boolean statistic metric associated with the plugin.
|
||||||
|
*/
|
||||||
|
enum class ObservablePlugins(
|
||||||
|
val title: String,
|
||||||
|
val metric: BooleanMetrics,
|
||||||
|
) {
|
||||||
|
DOKKA_PLUGIN("org.jetbrains.dokka", BooleanMetrics.ENABLED_DOKKA),
|
||||||
|
KOTLIN_JS_PLUGIN("org.jetbrains.kotlin.js", BooleanMetrics.KOTLIN_JS_PLUGIN_ENABLED),
|
||||||
|
COCOAPODS_PLUGIN("org.jetbrains.kotlin.native.cocoapods", BooleanMetrics.COCOAPODS_PLUGIN_ENABLED)
|
||||||
|
}
|
||||||
+6
-2
@@ -68,9 +68,13 @@ enum class BooleanMetrics(val type: BooleanOverridePolicy, val anonymization: Bo
|
|||||||
TESTS_EXECUTED(OVERRIDE, SAFE),
|
TESTS_EXECUTED(OVERRIDE, SAFE),
|
||||||
MAVEN_PUBLISH_EXECUTED(OVERRIDE, SAFE),
|
MAVEN_PUBLISH_EXECUTED(OVERRIDE, SAFE),
|
||||||
BUILD_FAILED(OVERRIDE, SAFE),
|
BUILD_FAILED(OVERRIDE, SAFE),
|
||||||
KOTLIN_COMPILATION_FAILED(OR, SAFE);
|
KOTLIN_COMPILATION_FAILED(OR, SAFE),
|
||||||
|
|
||||||
|
// Other plugins enabled
|
||||||
|
KOTLIN_JS_PLUGIN_ENABLED(OR, SAFE),
|
||||||
|
COCOAPODS_PLUGIN_ENABLED(OR, SAFE);
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val VERSION = 1
|
const val VERSION = 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ private const val STRING_METRICS_RELATIVE_PATH = "$SOURCE_CODE_RELATIVE_PATH/met
|
|||||||
private const val NUMERICAL_METRICS_RELATIVE_PATH = "$SOURCE_CODE_RELATIVE_PATH/metrics/NumericalMetrics.kt"
|
private const val NUMERICAL_METRICS_RELATIVE_PATH = "$SOURCE_CODE_RELATIVE_PATH/metrics/NumericalMetrics.kt"
|
||||||
|
|
||||||
private val STRING_METRICS_EXPECTED_VERSION_AND_HASH = Pair(1, "90347332db2ce54b51e7daa64595371e")
|
private val STRING_METRICS_EXPECTED_VERSION_AND_HASH = Pair(1, "90347332db2ce54b51e7daa64595371e")
|
||||||
private val BOOLEAN_METRICS_EXPECTED_VERSION_AND_HASH = Pair(1, "b1d0eb433e0df5544a33d4c944e66e45")
|
private val BOOLEAN_METRICS_EXPECTED_VERSION_AND_HASH = Pair(2, "c558be5bebec6dc07469cad384ac74d1")
|
||||||
private val NUMERICAL_METRICS_EXPECTED_VERSION_AND_HASH = Pair(1, "8fda0e0845f12f40346a9e4c5cae5989")
|
private val NUMERICAL_METRICS_EXPECTED_VERSION_AND_HASH = Pair(1, "8fda0e0845f12f40346a9e4c5cae5989")
|
||||||
private val SOURCE_FOLDER_EXPECTED_VERSION_AND_HASH =
|
private val SOURCE_FOLDER_EXPECTED_VERSION_AND_HASH =
|
||||||
Pair(
|
Pair(
|
||||||
|
|||||||
Reference in New Issue
Block a user