From c9fe10f5b868bead40be5908840d751d840cae8a Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 19 Nov 2020 18:06:03 -0800 Subject: Remove restriction on exported plugins that generate APIs hilt_android requires seven separate annotation processors, which is only feasible to support using exported_plugins to avoid having to list all seven in every module that uses it. Unfortunately they all set generates_api: true. Turbine is already disabled for modules that directly use a plugin that sets generates_api: true, because turbine doesn't run annotation processors. Also add support for disabling turbine if a module transitively uses a plugin that generates APIs via exported_plugins. Bug: 173397767 Test: TestExportedPlugins Change-Id: If70354a3dd67efb4ce88bc9c934d41ccb6241b28 --- java/java_test.go | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'java/java_test.go') diff --git a/java/java_test.go b/java/java_test.go index cf56e66da..3ab228bd2 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -315,8 +315,9 @@ func TestSimple(t *testing.T) { func TestExportedPlugins(t *testing.T) { type Result struct { - library string - processors string + library string + processors string + disableTurbine bool } var tests = []struct { name string @@ -375,6 +376,18 @@ func TestExportedPlugins(t *testing.T) { {library: "foo", processors: "-processor com.android.TestPlugin,com.android.TestPlugin2"}, }, }, + { + name: "Exports plugin to with generates_api to dependee", + extra: ` + java_library{name: "exports", exported_plugins: ["plugin_generates_api"]} + java_library{name: "foo", srcs: ["a.java"], libs: ["exports"]} + java_library{name: "bar", srcs: ["a.java"], static_libs: ["exports"]} + `, + results: []Result{ + {library: "foo", processors: "-processor com.android.TestPlugin", disableTurbine: true}, + {library: "bar", processors: "-processor com.android.TestPlugin", disableTurbine: true}, + }, + }, } for _, test := range tests { @@ -384,6 +397,11 @@ func TestExportedPlugins(t *testing.T) { name: "plugin", processor_class: "com.android.TestPlugin", } + java_plugin { + name: "plugin_generates_api", + generates_api: true, + processor_class: "com.android.TestPlugin", + } `+test.extra) for _, want := range test.results { @@ -391,6 +409,11 @@ func TestExportedPlugins(t *testing.T) { if javac.Args["processor"] != want.processors { t.Errorf("For library %v, expected %v, found %v", want.library, want.processors, javac.Args["processor"]) } + turbine := ctx.ModuleForTests(want.library, "android_common").MaybeRule("turbine") + disableTurbine := turbine.BuildParams.Rule == nil + if disableTurbine != want.disableTurbine { + t.Errorf("For library %v, expected disableTurbine %v, found %v", want.library, want.disableTurbine, disableTurbine) + } } }) } -- cgit v1.2.3-59-g8ed1b