summaryrefslogtreecommitdiff
path: root/sdk/java_sdk_test.go
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2020-01-13 21:03:22 +0000
committerPaul Duffin <paulduffin@google.com>2020-02-07 14:03:03 +0000
commit7b81f5e9d76d1db684b0cf6691f04833c628c7e4 (patch)
treeeb7d4c7264e1cd95aae10783af1eb92b059a56b0 /sdk/java_sdk_test.go
parentf4ae4f1390c0e0e34c1ad876d7df8abf16f8df1f (diff)
Add java_system_modules to sdk/module_exports
Adds an SdkMemberType implementation for java_system_modules. It specifies that java_system_modules can be used with sdk as well as module_exports, and also that the libs property should be included as transitive members in the sdk. It also adds support for treating appropriate tagged properties in the snapshot prebuilts module as references to sdk members so that they are correctly transformed when creating the versioned modules. Bug: 142940300 Test: m nothing Change-Id: Ic10b5a6d5b92b6018334fe876f06feaf79cc55e9
Diffstat (limited to 'sdk/java_sdk_test.go')
-rw-r--r--sdk/java_sdk_test.go133
1 files changed, 133 insertions, 0 deletions
diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go
index cc893b9ef..79d3c26e3 100644
--- a/sdk/java_sdk_test.go
+++ b/sdk/java_sdk_test.go
@@ -583,3 +583,136 @@ module_exports_snapshot {
checkMergeZip(".intermediates/myexports/linux_glibc_common/tmp/java/myjavaapistubs_stubs_sources.zip"),
)
}
+
+func TestSnapshotWithJavaSystemModules(t *testing.T) {
+ result := testSdkWithJava(t, `
+ sdk {
+ name: "mysdk",
+ java_system_modules: ["my-system-modules"],
+ }
+
+ java_system_modules {
+ name: "my-system-modules",
+ libs: ["system-module"],
+ }
+
+ java_library {
+ name: "system-module",
+ srcs: ["Test.java"],
+ sdk_version: "none",
+ system_modules: "none",
+ }
+ `)
+
+ result.CheckSnapshot("mysdk", "android_common", "",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+java_import {
+ name: "mysdk_system-module@current",
+ sdk_member_name: "system-module",
+ jars: ["java/system-module.jar"],
+}
+
+java_import {
+ name: "system-module",
+ prefer: false,
+ jars: ["java/system-module.jar"],
+}
+
+java_system_modules_import {
+ name: "mysdk_my-system-modules@current",
+ sdk_member_name: "my-system-modules",
+ libs: ["mysdk_system-module@current"],
+}
+
+java_system_modules_import {
+ name: "my-system-modules",
+ prefer: false,
+ libs: ["system-module"],
+}
+
+sdk_snapshot {
+ name: "mysdk@current",
+ java_system_modules: ["mysdk_my-system-modules@current"],
+}
+`),
+ checkAllCopyRules(".intermediates/system-module/android_common/turbine-combined/system-module.jar -> java/system-module.jar"),
+ )
+}
+
+func TestHostSnapshotWithJavaSystemModules(t *testing.T) {
+ // b/145598135 - Generating host snapshots for anything other than linux is not supported.
+ SkipIfNotLinux(t)
+
+ result := testSdkWithJava(t, `
+ sdk {
+ name: "mysdk",
+ device_supported: false,
+ host_supported: true,
+ java_system_modules: ["my-system-modules"],
+ }
+
+ java_system_modules {
+ name: "my-system-modules",
+ device_supported: false,
+ host_supported: true,
+ libs: ["system-module"],
+ }
+
+ java_library {
+ name: "system-module",
+ device_supported: false,
+ host_supported: true,
+ srcs: ["Test.java"],
+ sdk_version: "none",
+ system_modules: "none",
+ }
+ `)
+
+ result.CheckSnapshot("mysdk", "linux_glibc_common", "",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+java_import {
+ name: "mysdk_system-module@current",
+ sdk_member_name: "system-module",
+ device_supported: false,
+ host_supported: true,
+ jars: ["java/system-module.jar"],
+}
+
+java_import {
+ name: "system-module",
+ prefer: false,
+ device_supported: false,
+ host_supported: true,
+ jars: ["java/system-module.jar"],
+}
+
+java_system_modules_import {
+ name: "mysdk_my-system-modules@current",
+ sdk_member_name: "my-system-modules",
+ device_supported: false,
+ host_supported: true,
+ libs: ["mysdk_system-module@current"],
+}
+
+java_system_modules_import {
+ name: "my-system-modules",
+ prefer: false,
+ device_supported: false,
+ host_supported: true,
+ libs: ["system-module"],
+}
+
+sdk_snapshot {
+ name: "mysdk@current",
+ device_supported: false,
+ host_supported: true,
+ java_system_modules: ["mysdk_my-system-modules@current"],
+}
+`),
+ checkAllCopyRules(".intermediates/system-module/linux_glibc_common/javac/system-module.jar -> java/system-module.jar"),
+ )
+}