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

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

Go to download

Gradle support for the Collektive Kotlin compiler plugin, performing automatic aggregate alignment of Kotlin sources .

There is a newer version: 10.3.2
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 - 2024 Weber Informatics LLC | Privacy Policy