kotlinx.kover.gradle.plugin.dsl.internal.MergeImpl.kt Maven / Gradle / Ivy
/*
* Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package kotlinx.kover.gradle.plugin.dsl.internal
import kotlinx.kover.gradle.plugin.commons.KoverIllegalConfigException
import kotlinx.kover.gradle.plugin.dsl.*
import org.gradle.api.Action
import org.gradle.api.Project
import org.gradle.api.specs.Spec
internal abstract class KoverMergingConfigImpl: KoverMergingConfig {
internal val subprojectsFilters: MutableList> = mutableListOf()
internal val allProjectsFilters: MutableList> = mutableListOf()
internal var sourcesAction: Action? = null
internal var instrumentationAction: Action? = null
internal val variantsAction: MutableMap> = mutableMapOf()
override fun subprojects() {
subprojectsFilters += Spec { true }
}
override fun subprojects(filter: Spec) {
subprojectsFilters += filter
}
override fun allProjects() {
allProjectsFilters += Spec { true }
}
override fun allProjects(filter: Spec) {
allProjectsFilters += filter
}
override fun projects(vararg projectNameOrPath: String) {
allProjectsFilters += Spec { project -> project.name in projectNameOrPath || project.path in projectNameOrPath }
}
override fun sources(config: Action) {
if (sourcesAction != null) {
throw KoverIllegalConfigException("An attempt to re-invoke the 'sources' block in merging config. Only one usage is allowed")
}
sourcesAction = config
}
override fun instrumentation(config: Action) {
if (instrumentationAction != null) {
throw KoverIllegalConfigException("An attempt to re-invoke the 'instrumentation' block in merging config. Only one usage is allowed")
}
instrumentationAction = config
}
override fun createVariant(variantName: String, config: Action) {
val prev = variantsAction.put(variantName, config)
if (prev != null) {
throw KoverIllegalConfigException("Variant '$variantName' has already been added in merging config. Re-creating a variant with the same name is not allowed")
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy