summaryrefslogtreecommitdiff
path: root/java/base.go
diff options
context:
space:
mode:
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
commita1ff7c6926a68c841308c8d688c148dad22e56d6 (patch)
treec912a779442777d929dea9e93319666858670c15 /java/base.go
parenta0dc31d4a22a2ec0b1b02df968c9a7fd043f46c6 (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/base.go')
-rw-r--r--java/base.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/java/base.go b/java/base.go
index 86022c3b2..86e378b7e 100644
--- a/java/base.go
+++ b/java/base.go
@@ -643,6 +643,11 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
} else if j.shouldInstrumentStatic(ctx) {
ctx.AddVariationDependencies(nil, staticLibTag, "jacocoagent")
}
+
+ if j.useCompose() {
+ ctx.AddVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), kotlinPluginTag,
+ "androidx.compose.compiler_compiler-hosted")
+ }
}
func hasSrcExt(srcs []string, ext string) bool {
@@ -911,6 +916,12 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
if ctx.Device() {
kotlincFlags = append(kotlincFlags, "-no-jdk")
}
+
+ for _, plugin := range deps.kotlinPlugins {
+ kotlincFlags = append(kotlincFlags, "-Xplugin="+plugin.String())
+ }
+ flags.kotlincDeps = append(flags.kotlincDeps, deps.kotlinPlugins...)
+
if len(kotlincFlags) > 0 {
// optimization.
ctx.Variable(pctx, "kotlincFlags", strings.Join(kotlincFlags, " "))
@@ -1325,6 +1336,10 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
j.outputFile = outputFile.WithoutRel()
}
+func (j *Module) useCompose() bool {
+ return android.InList("androidx.compose.runtime_runtime", j.properties.Static_libs)
+}
+
// Returns a copy of the supplied flags, but with all the errorprone-related
// fields copied to the regular build's fields.
func enableErrorproneFlags(flags javaBuilderFlags) javaBuilderFlags {
@@ -1755,6 +1770,8 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
deps.kotlinStdlib = append(deps.kotlinStdlib, dep.HeaderJars...)
case kotlinAnnotationsTag:
deps.kotlinAnnotations = dep.HeaderJars
+ case kotlinPluginTag:
+ deps.kotlinPlugins = append(deps.kotlinPlugins, dep.ImplementationAndResourcesJars...)
case syspropPublicStubDepTag:
// This is a sysprop implementation library, forward the JavaInfoProvider from
// the corresponding sysprop public stub library as SyspropPublicStubInfoProvider.