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

it.unibo.collektive.GradlePlugin.kt Maven / Gradle / Ivy

There is a newer version: 12.2.1
Show newest version
package it.unibo.collektive

import org.gradle.api.Project
import org.gradle.api.provider.Provider
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerPluginSupportPlugin
import org.jetbrains.kotlin.gradle.plugin.SubpluginArtifact
import org.jetbrains.kotlin.gradle.plugin.SubpluginOption

/**
 * Gradle plugin that register the gradle extension and defines where the compiler
 * plugin is located.
 */
class GradlePlugin : KotlinCompilerPluginSupportPlugin {
    override fun apply(target: Project): Unit =
        with(target) {
            extensions.create("collektive", GradleExtension::class.java)
        }

    override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean = true

    override fun getCompilerPluginId(): String = BuildConfig.KOTLIN_PLUGIN_ID

    override fun getPluginArtifact(): SubpluginArtifact =
        SubpluginArtifact(
            groupId = BuildConfig.KOTLIN_PLUGIN_GROUP,
            artifactId = BuildConfig.KOTLIN_PLUGIN_NAME,
            version = BuildConfig.KOTLIN_PLUGIN_VERSION,
        )

    override fun applyToCompilation(kotlinCompilation: KotlinCompilation<*>): Provider> {
        val project = kotlinCompilation.target.project
        val extension = project.extensions.getByType(GradleExtension::class.java)
        return project.provider {
            listOf(
                SubpluginOption(key = "collektiveEnabled", value = extension.collektiveEnabled.get().toString()),
            )
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy