summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2021-02-04 11:15:34 +0000
committerPaul Duffin <paulduffin@google.com>2021-02-05 13:35:25 +0000
commit22ff0aaf51bdd9409eafe74151decb58f47308bc (patch)
tree90342540bc1b8d69a76aa58940f4bac70864e47a /java/java.go
parentdd63d6d7bdae32a1bf89a1ce8ade15ee10afd6cc (diff)
Export implementation class jars for java_boot_libs
Hiddenapi processing currently requires access to the class implementation jars for libraries on the bootclasspath which means that they need to be provided as part of the prebuilts. This change modifies the java_boot_libs property on the sdk to make those files available. Modularization of the hiddenapi processing will hopefully remove the need for these to be exported so this should be temporary. Bug: 178361284 Test: m art-module-sdk check generated snapshot zip contains implementation jars Change-Id: I9e94662dddb0ddb85a477ae6d27e533085147e88
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go35
1 files changed, 15 insertions, 20 deletions
diff --git a/java/java.go b/java/java.go
index 78d974b42..7d0b206ac 100644
--- a/java/java.go
+++ b/java/java.go
@@ -40,18 +40,21 @@ func init() {
// Register sdk member types.
android.RegisterSdkMemberType(javaHeaderLibsSdkMemberType)
+ // Export implementation classes jar as part of the sdk.
+ exportImplementationClassesJar := func(_ android.SdkMemberContext, j *Library) android.Path {
+ implementationJars := j.ImplementationAndResourcesJars()
+ if len(implementationJars) != 1 {
+ panic(fmt.Errorf("there must be only one implementation jar from %q", j.Name()))
+ }
+ return implementationJars[0]
+ }
+
// Register java implementation libraries for use only in module_exports (not sdk).
android.RegisterSdkMemberType(&librarySdkMemberType{
android.SdkMemberTypeBase{
PropertyName: "java_libs",
},
- func(_ android.SdkMemberContext, j *Library) android.Path {
- implementationJars := j.ImplementationAndResourcesJars()
- if len(implementationJars) != 1 {
- panic(fmt.Errorf("there must be only one implementation jar from %q", j.Name()))
- }
- return implementationJars[0]
- },
+ exportImplementationClassesJar,
sdkSnapshotFilePathForJar,
copyEverythingToSnapshot,
})
@@ -72,19 +75,11 @@ func init() {
PropertyName: "java_boot_libs",
SupportsSdk: true,
},
- func(ctx android.SdkMemberContext, j *Library) android.Path {
- // Java boot libs are only provided in the SDK to provide access to their dex implementation
- // jar for use by dexpreopting and boot jars package check. They do not need to provide an
- // actual implementation jar but the java_import will need a file that exists so just copy an
- // empty file. Any attempt to use that file as a jar will cause a build error.
- return ctx.SnapshotBuilder().EmptyFile()
- },
- func(osPrefix, name string) string {
- // Create a special name for the implementation jar to try and provide some useful information
- // to a developer that attempts to compile against this.
- // TODO(b/175714559): Provide a proper error message in Soong not ninja.
- return filepath.Join(osPrefix, "java_boot_libs", "snapshot", "jars", "are", "invalid", name+jarFileSuffix)
- },
+ // Temporarily export implementation classes jar for java_boot_libs as it is required for the
+ // hiddenapi processing.
+ // TODO(b/179354495): Revert once hiddenapi processing has been modularized.
+ exportImplementationClassesJar,
+ sdkSnapshotFilePathForJar,
onlyCopyJarToSnapshot,
})