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

com.javiersc.hubdle.project.extensions.kotlin.features.shared.HubdleKotlinContextReceiversFeatureExtension.kt Maven / Gradle / Ivy

There is a newer version: 0.7.18
Show newest version
package com.javiersc.hubdle.project.extensions.kotlin.features.shared

import com.javiersc.hubdle.project.extensions.HubdleDslMarker
import com.javiersc.hubdle.project.extensions._internal.getHubdleExtension
import com.javiersc.hubdle.project.extensions.apis.BaseHubdleExtension
import com.javiersc.hubdle.project.extensions.apis.HubdleConfigurableExtension
import com.javiersc.hubdle.project.extensions.apis.HubdleEnableableExtension
import com.javiersc.hubdle.project.extensions.apis.enableAndExecute
import com.javiersc.hubdle.project.extensions.kotlin.hubdleKotlinAny
import javax.inject.Inject
import org.gradle.api.Action
import org.gradle.api.Project
import org.gradle.api.provider.Property
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

public open class HubdleKotlinContextReceiversFeatureExtension
@Inject
constructor(project: Project) : HubdleConfigurableExtension(project) {

    override val isEnabled: Property = property { false }

    override val oneOfExtensions: Set
        get() = hubdleKotlinAny

    override fun Project.defaultConfiguration() {
        lazyConfigurable {
            tasks.withType().configureEach { task ->
                task.compilerOptions.freeCompilerArgs.add("-Xcontext-receivers")
            }
        }
    }
}

public interface HubdleKotlinContextReceiversDelegateFeatureExtension : BaseHubdleExtension {

    public val contextReceivers: HubdleKotlinContextReceiversFeatureExtension
        get() = project.getHubdleExtension()

    @HubdleDslMarker
    public fun contextReceivers(
        action: Action = Action {}
    ) {
        contextReceivers.enableAndExecute(action)
    }
}

internal val HubdleEnableableExtension.hubdleContextReceivers:
    HubdleKotlinContextReceiversFeatureExtension
    get() = getHubdleExtension()

internal val Project.hubdleContextReceivers: HubdleKotlinContextReceiversFeatureExtension
    get() = getHubdleExtension()




© 2015 - 2024 Weber Informatics LLC | Privacy Policy