From 13e67afca531d26ac112ad76f954b69f2f0561de Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Wed, 13 May 2020 10:17:56 +0100 Subject: [PATCH 1/2] Add framework-module-defaults for java_sdk_library Provides defaults for java_sdk_library to that are equivalent to those already used by the framework modules to simplify conversion. * The java_api_finder is in the defaults as that should be used by all mainline modules. * The public/system/module_lib scopes are explicitly specified in the defaults to include module_lib but exclude test as changing that behaviour by default would break upwards of 24 existing java_sdk_library usages. * The stubs for each API scope is compiled against module_current because if they compiled against the scope specific sdk version it would create cycles for "current" and "system_current" because some of the modules contribute to those. Test: m update-api Bug: 155164730 Merged-In: Icd5b893b080d3a8b92b11b856a71b700be96dafa Change-Id: Icd5b893b080d3a8b92b11b856a71b700be96dafa (cherry picked from commit bee7404dccbde59077a34d4bcfaab5ada4344617) --- apex/Android.bp | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/apex/Android.bp b/apex/Android.bp index c381c0f100a50..4a65550c616b2 100644 --- a/apex/Android.bp +++ b/apex/Android.bp @@ -63,6 +63,60 @@ mainline_service_stubs_args = "--hide-annotation android.annotation.Hide " + "--hide InternalClasses " // com.android.* classes are okay in this interface +// Defaults for mainline module provided java_sdk_library instances. +java_defaults { + name: "framework-module-defaults", + + // Additional annotations used for compiling both the implementation and the + // stubs libraries. + libs: ["framework-annotations-lib"], + + // Enable api lint. This will eventually become the default for java_sdk_library + // but it cannot yet be turned on because some usages have not been cleaned up. + // TODO(b/156126315) - Remove when no longer needed. + api_lint: { + enabled: true, + }, + + // The API scope specific properties. + public: { + enabled: true, + sdk_version: "module_current", + }, + system: { + enabled: true, + sdk_version: "module_current", + }, + module_lib: { + enabled: true, + sdk_version: "module_current", + }, + + // The stub libraries must be visible to frameworks/base so they can be combined + // into API specific libraries. + stubs_library_visibility: [ + "//frameworks/base", // Framework + ], + + // Set the visibility of the modules creating the stubs source. + stubs_source_visibility: [ + // Ignore any visibility rules specified on the java_sdk_library when + // setting the visibility of the stubs source modules. + "//visibility:override", + + // Currently, the stub source is not required for anything other than building + // the stubs library so is private to avoid misuse. + "//visibility:private", + ], + + // Collates API usages from each module for further analysis. + plugins: ["java_api_finder"], + + // Mainline modules should only rely on 'module_lib' APIs provided by other modules + // and the non updatable parts of the platform. + sdk_version: "module_current", +} + stubs_defaults { name: "framework-module-stubs-defaults-publicapi", args: mainline_framework_stubs_args, From df64dd19c000babde1b93da031fbc991aa09cbbf Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 28 Apr 2020 13:32:48 +0100 Subject: [PATCH 2/2] Switch framework-sdkextensions to use java_sdk_library The names of the individual modules do not quite follow the pattern that java_sdk_library uses so this temporarily sets the following: naming_scheme: "frameworks-modules" That causes java_sdk_library to use a naming scheme that matches the one used by the individual modules of this. It will be cleaned up later. Test: Removed API from current.txt, ran checkapi and it detected the API change. Ran update-api and it updated the API txt file. Added method without any nullability info, ran checkapi and API lint reported issues as expected. Bug: 155164730 Merged-In: Ifcdbfd77373710481343c9ff800543eaaa8c2ea8 Change-Id: Ifcdbfd77373710481343c9ff800543eaaa8c2ea8 (cherry picked from commit e01563f19f6286fd1bbe95d717f2fdde64f28c6e) --- apex/sdkextensions/Android.bp | 2 +- apex/sdkextensions/framework/Android.bp | 84 +++---------------------- 2 files changed, 9 insertions(+), 77 deletions(-) diff --git a/apex/sdkextensions/Android.bp b/apex/sdkextensions/Android.bp index dbb5bd3d660ff..fdb078e00d92e 100644 --- a/apex/sdkextensions/Android.bp +++ b/apex/sdkextensions/Android.bp @@ -39,7 +39,7 @@ apex_defaults { sdk { name: "sdkextensions-sdk", - java_header_libs: [ "framework-sdkextensions-stubs-systemapi" ], + java_sdk_libs: [ "framework-sdkextensions" ], } apex_key { diff --git a/apex/sdkextensions/framework/Android.bp b/apex/sdkextensions/framework/Android.bp index 6a787116c005f..b8aad7d8204f6 100644 --- a/apex/sdkextensions/framework/Android.bp +++ b/apex/sdkextensions/framework/Android.bp @@ -25,14 +25,18 @@ filegroup { visibility: [ "//frameworks/base" ] // For the "global" stubs. } -java_library { +java_sdk_library { name: "framework-sdkextensions", srcs: [ ":framework-sdkextensions-sources" ], - sdk_version: "system_current", - libs: [ "framework-annotations-lib" ], + defaults: ["framework-module-defaults"], + + // TODO(b/155480189) - Remove naming_scheme once references have been resolved. + // Temporary java_sdk_library component naming scheme to use to ease the transition from separate + // modules to java_sdk_library. + naming_scheme: "framework-modules", + permitted_packages: [ "android.os.ext" ], installable: true, - plugins: ["java_api_finder"], visibility: [ "//frameworks/base/apex/sdkextensions", "//frameworks/base/apex/sdkextensions/testing", @@ -43,75 +47,3 @@ java_library { "test_com.android.sdkext", ], } - -stubs_defaults { - name: "framework-sdkextensions-stubs-defaults", - srcs: [ ":framework-sdkextensions-sources" ], - libs: [ "framework-annotations-lib" ], - dist: { dest: "framework-sdkextensions.txt" }, -} - -droidstubs { - name: "framework-sdkextensions-stubs-srcs-publicapi", - defaults: [ - "framework-module-stubs-defaults-publicapi", - "framework-sdkextensions-stubs-defaults", - ], -} - -droidstubs { - name: "framework-sdkextensions-stubs-srcs-systemapi", - defaults: [ - "framework-module-stubs-defaults-systemapi", - "framework-sdkextensions-stubs-defaults", - ], -} - -droidstubs { - name: "framework-sdkextensions-api-module_libs_api", - defaults: [ - "framework-module-api-defaults-module_libs_api", - "framework-sdkextensions-stubs-defaults", - ], -} - -droidstubs { - name: "framework-sdkextensions-stubs-srcs-module_libs_api", - defaults: [ - "framework-module-stubs-defaults-module_libs_api", - "framework-sdkextensions-stubs-defaults", - ], -} - -java_library { - name: "framework-sdkextensions-stubs-publicapi", - srcs: [":framework-sdkextensions-stubs-srcs-publicapi"], - defaults: ["framework-module-stubs-lib-defaults-publicapi"], - visibility: [ - "//frameworks/base", // Framework - "//frameworks/base/apex/sdkextensions", // sdkextensions SDK - ], - dist: { dest: "framework-sdkextensions.jar" }, -} - -java_library { - name: "framework-sdkextensions-stubs-systemapi", - srcs: [":framework-sdkextensions-stubs-srcs-systemapi"], - defaults: ["framework-module-stubs-lib-defaults-systemapi"], - visibility: [ - "//frameworks/base", // Framework - "//frameworks/base/apex/sdkextensions", // sdkextensions SDK - ], - dist: { dest: "framework-sdkextensions.jar" }, -} - -java_library { - name: "framework-sdkextensions-stubs-module_libs_api", - srcs: [":framework-sdkextensions-stubs-srcs-module_libs_api"], - defaults: ["framework-module-stubs-lib-defaults-module_libs_api"], - visibility: [ - "//frameworks/base", // Framework - "//frameworks/base/apex/sdkextensions", // sdkextensions SDK - ], - dist: { dest: "framework-sdkextensions.jar" }, -}