Add missing dependency on compose plugin in kapt rules

The kapt rule uses kotlincFlags but was not using kotlincDeps,
causing the rule to get the -Xplugin argument on the compose
compiler plugin jar, but not have a dependency on it.

Bug: 231222079
Test: TestKotlinCompose
Change-Id: I4c2cf30fb7d8cad4eededa29f67f4ffd459caa41
(cherry picked from commit 08b0a1cd79)
Merged-In: I4c2cf30fb7d8cad4eededa29f67f4ffd459caa41
This commit is contained in:
Colin Cross 2022-05-02 13:59:33 -07:00 committed by Cherrypicker Worker
parent fe45ae8feb
commit dddb402c02
2 changed files with 9 additions and 0 deletions

View file

@ -175,6 +175,7 @@ func kotlinKapt(ctx android.ModuleContext, srcJarOutputFile, resJarOutputFile an
var deps android.Paths var deps android.Paths
deps = append(deps, flags.kotlincClasspath...) deps = append(deps, flags.kotlincClasspath...)
deps = append(deps, flags.kotlincDeps...)
deps = append(deps, srcJars...) deps = append(deps, srcJars...)
deps = append(deps, flags.processorPath...) deps = append(deps, flags.processorPath...)
deps = append(deps, commonSrcFiles...) deps = append(deps, commonSrcFiles...)

View file

@ -325,6 +325,7 @@ func TestKotlinCompose(t *testing.T) {
java_library { java_library {
name: "withcompose", name: "withcompose",
srcs: ["a.kt"], srcs: ["a.kt"],
plugins: ["plugin"],
static_libs: ["androidx.compose.runtime_runtime"], static_libs: ["androidx.compose.runtime_runtime"],
} }
@ -332,6 +333,10 @@ func TestKotlinCompose(t *testing.T) {
name: "nocompose", name: "nocompose",
srcs: ["a.kt"], srcs: ["a.kt"],
} }
java_plugin {
name: "plugin",
}
`) `)
buildOS := result.Config.BuildOS.String() buildOS := result.Config.BuildOS.String()
@ -346,6 +351,9 @@ func TestKotlinCompose(t *testing.T) {
android.AssertStringDoesContain(t, "missing compose compiler plugin", android.AssertStringDoesContain(t, "missing compose compiler plugin",
withCompose.VariablesForTestsRelativeToTop()["kotlincFlags"], "-Xplugin="+composeCompiler.String()) withCompose.VariablesForTestsRelativeToTop()["kotlincFlags"], "-Xplugin="+composeCompiler.String())
android.AssertStringListContains(t, "missing kapt compose compiler dependency",
withCompose.Rule("kapt").Implicits.Strings(), composeCompiler.String())
android.AssertStringListDoesNotContain(t, "unexpected compose compiler dependency", android.AssertStringListDoesNotContain(t, "unexpected compose compiler dependency",
noCompose.Rule("kotlinc").Implicits.Strings(), composeCompiler.String()) noCompose.Rule("kotlinc").Implicits.Strings(), composeCompiler.String())