commonMain.co.touchlab.skie.plugin.configuration.SkieExtensionInternals.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-plugin-impl-jvm Show documentation
Show all versions of gradle-plugin-impl-jvm Show documentation
Internal implementation for SKIE Gradle plugin.
@file:Suppress("MemberVisibilityCanBePrivate", "unused", "invisible_reference", "invisible_member")
package co.touchlab.skie.plugin.configuration
import co.touchlab.skie.configuration.SkieConfigurationFlag
import co.touchlab.skie.plugin.SkieTarget
import org.gradle.api.Project
fun SkieExtension.Companion.createExtension(project: Project): SkieExtension =
project.extensions.create("skie", SkieExtension::class.java)
val Project.skieExtension: SkieExtension
get() = project.extensions.getByType(SkieExtension::class.java)
fun SkieExtension.buildConfiguration(target: SkieTarget): GradleSkieConfigurationData =
GradleSkieConfigurationData(
enabledConfigurationFlags = getUserConfiguredFlags() + target.requiredConfigurationFlags,
groups = features.buildGroups() + build.buildGroup(),
)
private fun SkieExtension.getUserConfiguredFlags(): Set =
(mergeConfigurationSetsFromConfigurations() + additionalConfigurationFlags.get()) - suppressedConfigurationFlags.get()
private fun SkieExtension.mergeConfigurationSetsFromConfigurations(): Set =
analytics.buildConfigurationFlags() +
build.buildConfigurationFlags() +
debug.buildConfigurationFlags() +
features.buildConfigurationFlags() +
migration.buildConfigurationFlags()
private fun SkieFeatureConfiguration.buildGroups(): List =
groupConfigurations.map { it.build() }
private fun SkieFeatureConfiguration.GroupConfiguration.build(): GradleSkieConfigurationData.Group =
GradleSkieConfigurationData.Group(
target = targetFqNamePrefix,
overridesAnnotations = overridesAnnotations,
items = items.toMap(),
)
private fun SkieBuildConfiguration.buildGroup(): GradleSkieConfigurationData.Group =
GradleSkieConfigurationData.Group(
target = "",
overridesAnnotations = false,
items = buildItems(),
)