it.unibo.collektive.GradlePlugin.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-plugin Show documentation
Show all versions of gradle-plugin Show documentation
DSL for Aggregate Computing in Kotlin
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