Merge "Create java_api_contribution_import from sdk_library_import" into main am: 18a33e51c6
am: 578ece61ed
am: 567f0186a3
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2748475 Change-Id: Iffc00859104be5075a47822104d49aaf56cb5257 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -2479,6 +2479,10 @@ func (module *SdkLibraryImport) createInternalModules(mctx android.DefaultableHo
|
||||
if len(scopeProperties.Stub_srcs) > 0 {
|
||||
module.createPrebuiltStubsSources(mctx, apiScope, scopeProperties)
|
||||
}
|
||||
|
||||
if scopeProperties.Current_api != nil {
|
||||
module.createPrebuiltApiContribution(mctx, apiScope, scopeProperties)
|
||||
}
|
||||
}
|
||||
|
||||
javaSdkLibraries := javaSdkLibraries(mctx.Config())
|
||||
@@ -2534,6 +2538,25 @@ func (module *SdkLibraryImport) createPrebuiltStubsSources(mctx android.Defaulta
|
||||
mctx.CreateModule(PrebuiltStubsSourcesFactory, &props)
|
||||
}
|
||||
|
||||
func (module *SdkLibraryImport) createPrebuiltApiContribution(mctx android.DefaultableHookContext, apiScope *apiScope, scopeProperties *sdkLibraryScopeProperties) {
|
||||
api_file := scopeProperties.Current_api
|
||||
api_surface := &apiScope.name
|
||||
|
||||
props := struct {
|
||||
Name *string
|
||||
Api_surface *string
|
||||
Api_file *string
|
||||
Visibility []string
|
||||
}{}
|
||||
|
||||
props.Name = proptools.StringPtr(module.stubsSourceModuleName(apiScope) + ".api.contribution")
|
||||
props.Api_surface = api_surface
|
||||
props.Api_file = api_file
|
||||
props.Visibility = []string{"//visibility:override", "//visibility:public"}
|
||||
|
||||
mctx.CreateModule(ApiContributionImportFactory, &props)
|
||||
}
|
||||
|
||||
// Add the dependencies on the child module in the component deps mutator so that it
|
||||
// creates references to the prebuilt and not the source modules.
|
||||
func (module *SdkLibraryImport) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
|
@@ -74,6 +74,8 @@ func TestJavaSdkLibrary(t *testing.T) {
|
||||
name: "quuz",
|
||||
public: {
|
||||
jars: ["c.jar"],
|
||||
current_api: "api/current.txt",
|
||||
removed_api: "api/removed.txt",
|
||||
},
|
||||
}
|
||||
java_sdk_library_import {
|
||||
@@ -173,6 +175,9 @@ func TestJavaSdkLibrary(t *testing.T) {
|
||||
android.AssertDeepEquals(t, "qux exports (optional)", []string{}, optionalSdkLibs)
|
||||
}
|
||||
|
||||
// test if quuz have created the api_contribution module
|
||||
result.ModuleForTests(apiScopePublic.stubsSourceModuleName("quuz")+".api.contribution", "")
|
||||
|
||||
fooDexJar := result.ModuleForTests("foo", "android_common").Rule("d8")
|
||||
// tests if kotlinc generated files are NOT excluded from output of foo.
|
||||
android.AssertStringDoesNotContain(t, "foo dex", fooDexJar.BuildParams.Args["mergeZipsFlags"], "-stripFile META-INF/*.kotlin_module")
|
||||
|
Reference in New Issue
Block a user