Retry: "java_sdk_library: Control shared library use"

Previously, all java_sdk_library instances were assumed to be usable as
shared libraries, i.e. referenced from <uses-library> in Android
manifest. However, that was not true for any instances that specified
api_only: true and will not be true for many of the new Android
modules.

One consequence of this assumption is that use of one of the api_only
instances could (but fortunately does not appear to) have lead to an
invalid library being referenced in an app's manifest which would
prevent the app from loading. That would have been done automatically
by the implicit sdk library tracking and manifest fixing mechanism and
there would have been nothing a developer could have done about it.

Changes:
1) Prevents api_only instances from participating in the automatic
   tracking which will prevent them from being added to Android
   manifests and breaking apps.

2) Add a new shared_library property that can have the same effect as
   api_only while still creating a runtime implementation library.

3) Renamed commonProperties to commonSdkLibraryProperties to
   disambiguate it from the ModuleBase.commonProperties field.

4) Extracts requiresRuntimeImplementationLibrary() to remove duplicate
   code accessing the Api_only property.

5) Tests for the api_only and shared_library behaviours.

Test: m nothing - added tests, tests broke, fixed code, tests passed.
Bug: 156723295
(cherry picked from commit dfa131e673)
Change-Id: I06b3444ced00fd7b54068352187684171024c679
This commit is contained in:
Paul Duffin
2020-05-15 20:37:11 +01:00
parent 64e6199756
commit d11e78e641
2 changed files with 80 additions and 21 deletions

View File

@@ -1157,6 +1157,16 @@ func TestJavaSdkLibrary(t *testing.T) {
libs: ["foo", "bar.stubs"],
sdk_version: "system_current",
}
java_sdk_library {
name: "barney",
srcs: ["c.java"],
api_only: true,
}
java_sdk_library {
name: "betty",
srcs: ["c.java"],
shared_library: false,
}
java_sdk_library_import {
name: "quuz",
public: {
@@ -1169,10 +1179,17 @@ func TestJavaSdkLibrary(t *testing.T) {
jars: ["b.jar"],
},
}
java_sdk_library_import {
name: "wilma",
public: {
jars: ["b.jar"],
},
shared_library: false,
}
java_library {
name: "qux",
srcs: ["c.java"],
libs: ["baz", "fred", "quuz.stubs"],
libs: ["baz", "fred", "quuz.stubs", "wilma", "barney", "betty"],
sdk_version: "system_current",
}
java_library {