diff options
author | Colin Cross <ccross@android.com> | 2021-09-17 14:11:52 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2021-09-20 09:12:42 -0700 |
commit | a1ff7c6926a68c841308c8d688c148dad22e56d6 (patch) | |
tree | c912a779442777d929dea9e93319666858670c15 /java/kotlin_test.go | |
parent | a0dc31d4a22a2ec0b1b02df968c9a7fd043f46c6 (diff) |
Enable compose kotlinc plugin when depending on the compose runtime
When a module depends on the compose runtime add a -Xplugin argument
to the kotlinc flags that enables the compose compiler plugin.
Bug: 196351110
Test: TestKotlinCompose
Change-Id: I423a3c4d12df42804a24b672a40a165bc8dd165f
Diffstat (limited to 'java/kotlin_test.go')
-rw-r--r-- | java/kotlin_test.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/java/kotlin_test.go b/java/kotlin_test.go index db3069693..cac0af3b9 100644 --- a/java/kotlin_test.go +++ b/java/kotlin_test.go @@ -281,3 +281,46 @@ func TestKaptEncodeFlags(t *testing.T) { }) } } + +func TestKotlinCompose(t *testing.T) { + result := android.GroupFixturePreparers( + PrepareForTestWithJavaDefaultModules, + ).RunTestWithBp(t, ` + java_library { + name: "androidx.compose.runtime_runtime", + } + + java_library_host { + name: "androidx.compose.compiler_compiler-hosted", + } + + java_library { + name: "withcompose", + srcs: ["a.kt"], + static_libs: ["androidx.compose.runtime_runtime"], + } + + java_library { + name: "nocompose", + srcs: ["a.kt"], + } + `) + + buildOS := result.Config.BuildOS.String() + + composeCompiler := result.ModuleForTests("androidx.compose.compiler_compiler-hosted", buildOS+"_common").Rule("combineJar").Output + withCompose := result.ModuleForTests("withcompose", "android_common") + noCompose := result.ModuleForTests("nocompose", "android_common") + + android.AssertStringListContains(t, "missing compose compiler dependency", + withCompose.Rule("kotlinc").Implicits.Strings(), composeCompiler.String()) + + android.AssertStringDoesContain(t, "missing compose compiler plugin", + withCompose.VariablesForTestsRelativeToTop()["kotlincFlags"], "-Xplugin="+composeCompiler.String()) + + android.AssertStringListDoesNotContain(t, "unexpected compose compiler dependency", + noCompose.Rule("kotlinc").Implicits.Strings(), composeCompiler.String()) + + android.AssertStringDoesNotContain(t, "unexpected compose compiler plugin", + noCompose.VariablesForTestsRelativeToTop()["kotlincFlags"], "-Xplugin="+composeCompiler.String()) +} |