Merge "Return the header jar of the implementation library in SdkHeaderJars()" into main
This commit is contained in:
@@ -7334,7 +7334,7 @@ func TestJavaSDKLibrary_WithinApex(t *testing.T) {
|
|||||||
|
|
||||||
// The bar library should depend on the implementation jar.
|
// The bar library should depend on the implementation jar.
|
||||||
barLibrary := ctx.ModuleForTests("bar", "android_common_myapex").Rule("javac")
|
barLibrary := ctx.ModuleForTests("bar", "android_common_myapex").Rule("javac")
|
||||||
if expected, actual := `^-classpath [^:]*/turbine-combined/foo\.jar$`, barLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) {
|
if expected, actual := `^-classpath [^:]*/turbine-combined/foo\.impl\.jar$`, barLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) {
|
||||||
t.Errorf("expected %q, found %#q", expected, actual)
|
t.Errorf("expected %q, found %#q", expected, actual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -949,6 +949,10 @@ type commonToSdkLibraryAndImport struct {
|
|||||||
|
|
||||||
// Functionality related to this being used as a component of a java_sdk_library.
|
// Functionality related to this being used as a component of a java_sdk_library.
|
||||||
EmbeddableSdkLibraryComponent
|
EmbeddableSdkLibraryComponent
|
||||||
|
|
||||||
|
// Path to the header jars of the implementation library
|
||||||
|
// This is non-empty only when api_only is false.
|
||||||
|
implLibraryHeaderJars android.Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *commonToSdkLibraryAndImport) initCommon(module commonSdkLibraryAndImportModule) {
|
func (c *commonToSdkLibraryAndImport) initCommon(module commonSdkLibraryAndImportModule) {
|
||||||
@@ -1356,13 +1360,6 @@ type SdkLibraryDependency interface {
|
|||||||
// class changes but it does not contain and implementation or JavaDoc.
|
// class changes but it does not contain and implementation or JavaDoc.
|
||||||
SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths
|
SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths
|
||||||
|
|
||||||
// Get the implementation jars appropriate for the supplied sdk version.
|
|
||||||
//
|
|
||||||
// These are either the implementation jar for the whole sdk library or the implementation
|
|
||||||
// jars for the stubs. The latter should only be needed when generating JavaDoc as otherwise
|
|
||||||
// they are identical to the corresponding header jars.
|
|
||||||
SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths
|
|
||||||
|
|
||||||
// SdkApiStubDexJar returns the dex jar for the stubs for the prebuilt
|
// SdkApiStubDexJar returns the dex jar for the stubs for the prebuilt
|
||||||
// java_sdk_library_import module. It is needed by the hiddenapi processing tool which
|
// java_sdk_library_import module. It is needed by the hiddenapi processing tool which
|
||||||
// processes dex files.
|
// processes dex files.
|
||||||
@@ -1599,6 +1596,12 @@ func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
|||||||
|
|
||||||
exportedComponents[ctx.OtherModuleName(to)] = struct{}{}
|
exportedComponents[ctx.OtherModuleName(to)] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if tag == implLibraryTag {
|
||||||
|
if dep, ok := android.OtherModuleProvider(ctx, to, JavaInfoProvider); ok {
|
||||||
|
module.implLibraryHeaderJars = append(module.implLibraryHeaderJars, dep.HeaderJars...)
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Make the set of components exported by this module available for use elsewhere.
|
// Make the set of components exported by this module available for use elsewhere.
|
||||||
@@ -2238,7 +2241,7 @@ func withinSameApexesAs(ctx android.BaseModuleContext, other android.Module) boo
|
|||||||
return len(otherApexInfo.InApexVariants) > 0 && reflect.DeepEqual(apexInfo.InApexVariants, otherApexInfo.InApexVariants)
|
return len(otherApexInfo.InApexVariants) > 0 && reflect.DeepEqual(apexInfo.InApexVariants, otherApexInfo.InApexVariants)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec, headerJars bool) android.Paths {
|
func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths {
|
||||||
// If the client doesn't set sdk_version, but if this library prefers stubs over
|
// If the client doesn't set sdk_version, but if this library prefers stubs over
|
||||||
// the impl library, let's provide the widest API surface possible. To do so,
|
// the impl library, let's provide the widest API surface possible. To do so,
|
||||||
// force override sdk_version to module_current so that the closest possible API
|
// force override sdk_version to module_current so that the closest possible API
|
||||||
@@ -2255,11 +2258,7 @@ func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion andr
|
|||||||
// * No sdk_version specified on the referencing module.
|
// * No sdk_version specified on the referencing module.
|
||||||
// * The referencing module is in the same apex as this.
|
// * The referencing module is in the same apex as this.
|
||||||
if sdkVersion.Kind == android.SdkPrivate || withinSameApexesAs(ctx, module) {
|
if sdkVersion.Kind == android.SdkPrivate || withinSameApexesAs(ctx, module) {
|
||||||
if headerJars {
|
return module.implLibraryHeaderJars
|
||||||
return module.HeaderJars()
|
|
||||||
} else {
|
|
||||||
return module.ImplementationJars()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2268,12 +2267,7 @@ func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion andr
|
|||||||
|
|
||||||
// to satisfy SdkLibraryDependency interface
|
// to satisfy SdkLibraryDependency interface
|
||||||
func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths {
|
func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths {
|
||||||
return module.sdkJars(ctx, sdkVersion, true /*headerJars*/)
|
return module.sdkJars(ctx, sdkVersion)
|
||||||
}
|
|
||||||
|
|
||||||
// to satisfy SdkLibraryDependency interface
|
|
||||||
func (module *SdkLibrary) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths {
|
|
||||||
return module.sdkJars(ctx, sdkVersion, false /*headerJars*/)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var javaSdkLibrariesKey = android.NewOnceKey("javaSdkLibraries")
|
var javaSdkLibrariesKey = android.NewOnceKey("javaSdkLibraries")
|
||||||
@@ -2983,12 +2977,6 @@ func (module *SdkLibraryImport) SdkHeaderJars(ctx android.BaseModuleContext, sdk
|
|||||||
return module.sdkJars(ctx, sdkVersion, true)
|
return module.sdkJars(ctx, sdkVersion, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// to satisfy SdkLibraryDependency interface
|
|
||||||
func (module *SdkLibraryImport) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths {
|
|
||||||
// This module is just a wrapper for the stubs.
|
|
||||||
return module.sdkJars(ctx, sdkVersion, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
// to satisfy UsesLibraryDependency interface
|
// to satisfy UsesLibraryDependency interface
|
||||||
func (module *SdkLibraryImport) DexJarBuildPath(ctx android.ModuleErrorfContext) OptionalDexJarPath {
|
func (module *SdkLibraryImport) DexJarBuildPath(ctx android.ModuleErrorfContext) OptionalDexJarPath {
|
||||||
// The dex implementation jar extracted from the .apex file should be used in preference to the
|
// The dex implementation jar extracted from the .apex file should be used in preference to the
|
||||||
|
Reference in New Issue
Block a user