summaryrefslogtreecommitdiff
path: root/java/kotlin_test.go
diff options
context:
space:
mode:
author Luca Stefani <luca.stefani.ge1@gmail.com> 2024-10-12 17:55:31 +0200
committer Luca Stefani <luca.stefani.ge1@gmail.com> 2024-10-17 21:01:28 +0200
commit50098f775360a2b49ac981685dffb45366722b97 (patch)
treee9d86852f738baae570b1bdfbdcfa7b4c917b354 /java/kotlin_test.go
parent991d11df34cc11d0dd71c8e4334fc3fc9e28e054 (diff)
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
Diffstat (limited to 'java/kotlin_test.go')
-rw-r--r--java/kotlin_test.go53
1 files changed, 50 insertions, 3 deletions
diff --git a/java/kotlin_test.go b/java/kotlin_test.go
index f6e7fcaaa..45eac0134 100644
--- a/java/kotlin_test.go
+++ b/java/kotlin_test.go
@@ -500,8 +500,8 @@ func TestKotlinCompose(t *testing.T) {
name: "androidx.compose.runtime_runtime",
}
- java_library_host {
- name: "androidx.compose.compiler_compiler-hosted",
+ kotlin_plugin {
+ name: "androidx.compose.compiler_compiler-hosted-plugin",
}
java_library {
@@ -523,7 +523,7 @@ func TestKotlinCompose(t *testing.T) {
buildOS := result.Config.BuildOS.String()
- composeCompiler := result.ModuleForTests("androidx.compose.compiler_compiler-hosted", buildOS+"_common").Rule("combineJar").Output
+ composeCompiler := result.ModuleForTests("androidx.compose.compiler_compiler-hosted-plugin", buildOS+"_common").Rule("combineJar").Output
withCompose := result.ModuleForTests("withcompose", "android_common")
noCompose := result.ModuleForTests("nocompose", "android_common")
@@ -542,3 +542,50 @@ func TestKotlinCompose(t *testing.T) {
android.AssertStringDoesNotContain(t, "unexpected compose compiler plugin",
noCompose.VariablesForTestsRelativeToTop()["kotlincFlags"], "-Xplugin="+composeCompiler.String())
}
+
+func TestKotlinPlugin(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ ).RunTestWithBp(t, `
+ kotlin_plugin {
+ name: "kotlin_plugin",
+ }
+
+ java_library {
+ name: "with_kotlin_plugin",
+ srcs: ["a.kt"],
+ plugins: ["plugin"],
+ kotlin_plugins: ["kotlin_plugin"],
+ }
+
+ java_library {
+ name: "no_kotlin_plugin",
+ srcs: ["a.kt"],
+ }
+
+ java_plugin {
+ name: "plugin",
+ }
+ `)
+
+ buildOS := result.Config.BuildOS.String()
+
+ kotlinPlugin := result.ModuleForTests("kotlin_plugin", buildOS+"_common").Rule("combineJar").Output
+ withKotlinPlugin := result.ModuleForTests("with_kotlin_plugin", "android_common")
+ noKotlinPlugin := result.ModuleForTests("no_kotlin_plugin", "android_common")
+
+ android.AssertStringListContains(t, "missing plugin compiler dependency",
+ withKotlinPlugin.Rule("kotlinc").Implicits.Strings(), kotlinPlugin.String())
+
+ android.AssertStringDoesContain(t, "missing kotlin plugin",
+ withKotlinPlugin.VariablesForTestsRelativeToTop()["kotlincFlags"], "-Xplugin="+kotlinPlugin.String())
+
+ android.AssertStringListContains(t, "missing kapt kotlin plugin dependency",
+ withKotlinPlugin.Rule("kapt").Implicits.Strings(), kotlinPlugin.String())
+
+ android.AssertStringListDoesNotContain(t, "unexpected kotlin plugin dependency",
+ noKotlinPlugin.Rule("kotlinc").Implicits.Strings(), kotlinPlugin.String())
+
+ android.AssertStringDoesNotContain(t, "unexpected kotlin plugin",
+ noKotlinPlugin.VariablesForTestsRelativeToTop()["kotlincFlags"], "-Xplugin="+kotlinPlugin.String())
+}