summaryrefslogtreecommitdiff
path: root/java/base.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2023-07-18 22:11:07 -0700
committer Colin Cross <ccross@android.com> 2023-07-19 21:48:11 +0000
commitf06d8dc8e3816cef2d3c0ba072ad1fc24bc44de0 (patch)
tree3c11e774025d25357223c33724284bd595db86d0 /java/base.go
parent12a1f9182d41fc08aee18ece94a30177bccb273c (diff)
Strip META-INF/services from implementation jars when using as header jars
If a header jar couldn't be built (for example when an API generating annoation processor is in use) the implementation jar is reused as the header jar. If the implementation jar contains an annotation processor listed in META-INF/services/javax.annotation.processing.Processor then later javac executions with the implementation jar in the classpath could attempt to run the annotation processors unexpectedly. Remove the META-INF/services directory when using an implementation jar as a header jar. Bug: 290933559 Test: builds Change-Id: I40d48644bc5a09a9564dc2c4b38f627edd00fcf8
Diffstat (limited to 'java/base.go')
-rw-r--r--java/base.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/java/base.go b/java/base.go
index 8db716256..795a4b701 100644
--- a/java/base.go
+++ b/java/base.go
@@ -1477,7 +1477,13 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
j.implementationJarFile = outputFile
if j.headerJarFile == nil {
- j.headerJarFile = j.implementationJarFile
+ // If this module couldn't generate a header jar (for example due to api generating annotation processors)
+ // then use the implementation jar. Run it through zip2zip first to remove any files in META-INF/services
+ // so that javac on modules that depend on this module don't pick up annotation processors (which may be
+ // missing their implementations) from META-INF/services/javax.annotation.processing.Processor.
+ headerJarFile := android.PathForModuleOut(ctx, "javac-header", jarName)
+ convertImplementationJarToHeaderJar(ctx, j.implementationJarFile, headerJarFile)
+ j.headerJarFile = headerJarFile
}
// enforce syntax check to jacoco filters for any build (http://b/183622051)