From 50098f775360a2b49ac981685dffb45366722b97 Mon Sep 17 00:00:00 2001 From: Luca Stefani Date: Sat, 12 Oct 2024 17:55:31 +0200 Subject: Add support for kotlin plugins Use the already existing hooks used by the compose compiler plugin to support kotlin plugins bundled alongside the compiler such as kotlin-serialize-compiler Test: m, sample app with kotlin-serialize-compiler Change-Id: I4d5fa6cd42acfc90ef437222e9e07f61c259d565 --- java/base.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'java/base.go') diff --git a/java/base.go b/java/base.go index a9399cbd3..19f6c5d09 100644 --- a/java/base.go +++ b/java/base.go @@ -113,6 +113,9 @@ type CommonProperties struct { // List of modules to use as annotation processors Plugins []string + // List of modules to use as kotlin plugin + Kotlin_plugins []string + // List of modules to export to libraries that directly depend on this library as annotation // processors. Note that if the plugins set generates_api: true this will disable the turbine // optimization on modules that depend on this module, which will reduce parallelism and cause @@ -872,6 +875,7 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) { } ctx.AddFarVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), pluginTag, j.properties.Plugins...) + ctx.AddFarVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), kotlinPluginTag, j.properties.Kotlin_plugins...) ctx.AddFarVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), errorpronePluginTag, j.properties.Errorprone.Extra_check_modules...) ctx.AddFarVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), exportedPluginTag, j.properties.Exported_plugins...) @@ -904,7 +908,7 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) { if j.useCompose(ctx) { ctx.AddVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), kotlinPluginTag, - "androidx.compose.compiler_compiler-hosted") + "androidx.compose.compiler_compiler-hosted-plugin") } } @@ -2499,7 +2503,11 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { ctx.PropertyErrorf("exported_plugins", "%q is not a java_plugin module", otherName) } case kotlinPluginTag: - deps.kotlinPlugins = append(deps.kotlinPlugins, dep.ImplementationAndResourcesJars...) + if _, ok := module.(*KotlinPlugin); ok { + deps.kotlinPlugins = append(deps.kotlinPlugins, dep.ImplementationAndResourcesJars...) + } else { + ctx.PropertyErrorf("kotlin_plugins", "%q is not a kotlin_plugin module", otherName) + } case syspropPublicStubDepTag: // This is a sysprop implementation library, forward the JavaInfoProvider from // the corresponding sysprop public stub library as SyspropPublicStubInfoProvider. -- cgit v1.2.3-59-g8ed1b