From 1cad3a53db591d5f40d4a7d7ac883fd10763fd98 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Fri, 29 Oct 2021 13:30:59 +0100 Subject: Make prebuilt_api test environment realistic Previously, the fixture preparer for prebuilt_apis would add a core-for-system-modules.jar file in every API directory even though currently they only exist in the public API directories. This change makes the test environment more realistic by only creating them for the public API. Rather than hard code that into the test code (which would duplicate the hard coding in the decodeSdkDep func) this extracts a function that is used by both. That ensures that any changes to that func will be reflected in both the test and runtime behavior. Bug: 204189791 Test: m nothing Change-Id: I346ac9c0dcf407c61de16b6027663a05821bcf62 --- java/sdk.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'java/sdk.go') diff --git a/java/sdk.go b/java/sdk.go index 3c6b23463..42ed14f74 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -60,6 +60,12 @@ func defaultJavaLanguageVersion(ctx android.EarlyModuleContext, s android.SdkSpe } } +// systemModuleKind returns the kind of system modules to use. +func systemModuleKind() android.SdkKind { + // Currently, every sdk version uses the system modules for the public API. + return android.SdkPublic +} + func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext) sdkDep { sdkVersion := sdkContext.SdkVersion(ctx) if !sdkVersion.Valid() { @@ -105,7 +111,8 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext) var systemModules string if defaultJavaLanguageVersion(ctx, sdkVersion).usesJavaModules() { - systemModules = "sdk_public_" + sdkVersion.ApiLevel.String() + "_system_modules" + systemModuleKind := systemModuleKind() + systemModules = fmt.Sprintf("sdk_%s_%s_system_modules", systemModuleKind, sdkVersion.ApiLevel) } return sdkDep{ -- cgit v1.2.3-59-g8ed1b