All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.co.touchlab.skie.plugin.configuration.SkieExtensionInternals.kt Maven / Gradle / Ivy

There is a newer version: 0.9.0-RC.5
Show newest version
@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(),
    )




© 2015 - 2024 Weber Informatics LLC | Privacy Policy