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

zsu.cacheable.kcp.CacheableGradlePlugin.kt Maven / Gradle / Ivy

There is a newer version: 0.0.9-beta
Show newest version
package zsu.cacheable.kcp

import host.bytedance.BuildConfig
import org.gradle.api.Project
import org.gradle.api.provider.Provider
import org.jetbrains.kotlin.gradle.plugin.*

@Suppress("unused")
class CacheableGradlePlugin : KotlinCompilerPluginSupportPlugin {
    override fun apply(target: Project) {
        super.apply(target)
        val runtimeArtifact = "${BuildConfig.GROUP}:${BuildConfig.RUNTIME_NAME}:${BuildConfig.VERSION}"
        target.dependencies.add("implementation", runtimeArtifact)
    }

    override fun applyToCompilation(kotlinCompilation: KotlinCompilation<*>): Provider> {
        return kotlinCompilation.target.project.provider { emptyList() }
    }

    override fun getCompilerPluginId(): String = "zsu.kotlin-cacheable-kcp"

    private val artifact = SubpluginArtifact(
        BuildConfig.GROUP, BuildConfig.KCP_NAME, BuildConfig.VERSION,
    )

    override fun getPluginArtifact(): SubpluginArtifact = artifact

    // sadly, support jvm only currently.
    override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean =
        when (kotlinCompilation.platformType) {
            KotlinPlatformType.jvm, KotlinPlatformType.androidJvm -> true
            else -> false
        }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy