ru.tinkoff.plugins.buildmetrics.gradle.labels.internal.BuildOperationsLabelsFactory.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.labels.internal
import org.gradle.internal.configurationcache.ConfigurationCacheLoadBuildOperationType
import org.gradle.internal.configurationcache.ConfigurationCacheStoreBuildOperationType
import org.gradle.tooling.provider.model.internal.QueryToolingModelBuildOperationType
import ru.tinkoff.plugins.buildmetrics.api.builds.internal.BuildOperationData
import ru.tinkoff.plugins.buildmetrics.api.builds.internal.BuildOperationDataListener
import ru.tinkoff.plugins.buildmetrics.api.factories.Factory
import ru.tinkoff.plugins.buildmetrics.api.labels.Label
/**
* Labels:
* - gradle_tooling_used;
* - gradle_configuration_cache_reused;
*/
class BuildOperationsLabelsFactory : Factory.Labels, BuildOperationDataListener {
private class FactoryData {
var gradleToolingUsed: Boolean = false
private set
var configurationCacheLoaded: Boolean = false
private set
var configurationCacheStored: Boolean = false
private set
val configurationCacheReused: Boolean
get() = configurationCacheLoaded && configurationCacheStored.not()
fun onBuildOperationData(data: BuildOperationData) {
when(data.details) {
is QueryToolingModelBuildOperationType.Details -> gradleToolingUsed = true
is ConfigurationCacheLoadBuildOperationType.Details -> configurationCacheLoaded = true
is ConfigurationCacheStoreBuildOperationType.Details -> configurationCacheStored = true
}
}
}
@Transient
private var factoryData: FactoryData = FactoryData()
override fun reinitialize() {
factoryData = FactoryData()
}
override fun onBuildOperationData(data: BuildOperationData) {
factoryData.onBuildOperationData(data = data)
}
override fun create(): List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy