ru.tinkoff.plugins.buildmetrics.gradle.SetupBuildMetricsExtension.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of build-metrics-gradle Show documentation
Show all versions of build-metrics-gradle Show documentation
Extension for tinkoff build metrics gradle plugin.
package ru.tinkoff.plugins.buildmetrics.gradle
import org.gradle.api.configuration.BuildFeatures
import org.gradle.api.invocation.BuildInvocationDetails
import org.gradle.api.invocation.Gradle
import ru.tinkoff.plugins.buildmetrics.api.extensions.BuildMetricsExtension
import ru.tinkoff.plugins.buildmetrics.api.extensions.handlers.LabelsHandler
import ru.tinkoff.plugins.buildmetrics.api.extensions.handlers.MetricsHandler
import ru.tinkoff.plugins.buildmetrics.gradle.labels.BuildResultLabelsFactory
import ru.tinkoff.plugins.buildmetrics.gradle.labels.GradleLabelsFactory
import ru.tinkoff.plugins.buildmetrics.gradle.labels.internal.BuildOperationsLabelsFactory
import ru.tinkoff.plugins.buildmetrics.gradle.metrics.BuildResultMetricsFactory
import ru.tinkoff.plugins.buildmetrics.gradle.metrics.internal.BuildCacheMetricsFactory
import ru.tinkoff.plugins.buildmetrics.gradle.metrics.internal.BuildDurationMetricsFactory
import ru.tinkoff.plugins.buildmetrics.gradle.metrics.internal.BuildFailuresMetricsFactory
import ru.tinkoff.plugins.buildmetrics.gradle.metrics.internal.BuildNetworkMetricsFactory
import ru.tinkoff.plugins.buildmetrics.gradle.metrics.internal.BuildOperationsMetricsFactory
import ru.tinkoff.plugins.buildmetrics.gradle.metrics.internal.BuildTasksMetricsFactory
fun MetricsHandler.addGradleMetrics(
buildDetails: BuildInvocationDetails,
maxTaskFailures: Int,
) {
add(BuildResultMetricsFactory())
add(BuildCacheMetricsFactory())
add(BuildNetworkMetricsFactory())
add(BuildOperationsMetricsFactory())
add(BuildFailuresMetricsFactory(maxTaskFailures = maxTaskFailures))
add(BuildTasksMetricsFactory())
add(BuildDurationMetricsFactory(buildDetails = buildDetails))
}
fun LabelsHandler.addGradleLabels(gradle: Gradle, buildFeatures: BuildFeatures) {
add(GradleLabelsFactory(gradle = gradle, buildFeatures = buildFeatures))
add(BuildResultLabelsFactory())
add(BuildOperationsLabelsFactory())
}
@Suppress("unused")
fun BuildMetricsExtension.addGradleMetricsAndLabels(
buildDetails: BuildInvocationDetails,
buildFeatures: BuildFeatures,
gradle: Gradle,
maxTaskFailures: Int,
) {
metrics {
addGradleMetrics(buildDetails = buildDetails, maxTaskFailures = maxTaskFailures)
}
labels {
addGradleLabels(gradle = gradle, buildFeatures = buildFeatures)
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy