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 --- android/neverallow.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'android/neverallow.go') diff --git a/android/neverallow.go b/android/neverallow.go index 439fe2df8..57373d5b9 100644 --- a/android/neverallow.go +++ b/android/neverallow.go @@ -62,6 +62,7 @@ func init() { AddNeverAllowRules(createLimitNdkExportRule()...) AddNeverAllowRules(createLimitDirgroupRule()...) AddNeverAllowRules(createFilesystemIsAutoGeneratedRule()) + AddNeverAllowRules(createKotlinPluginRule()...) } // Add a NeverAllow rule to the set of rules to apply. @@ -302,6 +303,22 @@ func createFilesystemIsAutoGeneratedRule() Rule { Because("is_auto_generated property is only allowed for filesystem modules in build/soong/fsgen directory") } +func createKotlinPluginRule() []Rule { + kotlinPluginProjectsAllowedList := []string{ + // TODO: Migrate compose plugin to the bundled compiler plugin + // Actual path prebuilts/sdk/current/androidx/m2repository/androidx/compose/compiler/compiler-hosted + "prebuilts/sdk/current/androidx", + "external/kotlinc", + } + + return []Rule{ + NeverAllow(). + NotIn(kotlinPluginProjectsAllowedList...). + ModuleType("kotlin_plugin"). + Because("kotlin_plugin can only be used in allowed projects"), + } +} + func neverallowMutator(ctx BottomUpMutatorContext) { m, ok := ctx.Module().(Module) if !ok { -- cgit v1.2.3-59-g8ed1b