Merge changes Ib4581079,Ia3887bae into main
* changes: Make IdeInfo aware of jarjar-ing Add .internal modules to IDEInfo.deps of top-level java_sdk_library
This commit is contained in:
14
java/base.go
14
java/base.go
@@ -2027,16 +2027,20 @@ func (j *Module) ClassLoaderContexts() dexpreopt.ClassLoaderContextMap {
|
|||||||
|
|
||||||
// Collect information for opening IDE project files in java/jdeps.go.
|
// Collect information for opening IDE project files in java/jdeps.go.
|
||||||
func (j *Module) IDEInfo(dpInfo *android.IdeInfo) {
|
func (j *Module) IDEInfo(dpInfo *android.IdeInfo) {
|
||||||
dpInfo.Deps = append(dpInfo.Deps, j.CompilerDeps()...)
|
// jarjar rules will repackage the sources. To prevent misleading results, IdeInfo should contain the
|
||||||
dpInfo.Srcs = append(dpInfo.Srcs, j.expandIDEInfoCompiledSrcs...)
|
// repackaged jar instead of the input sources.
|
||||||
dpInfo.SrcJars = append(dpInfo.SrcJars, j.compiledSrcJars.Strings()...)
|
|
||||||
dpInfo.Aidl_include_dirs = append(dpInfo.Aidl_include_dirs, j.deviceProperties.Aidl.Include_dirs...)
|
|
||||||
if j.expandJarjarRules != nil {
|
if j.expandJarjarRules != nil {
|
||||||
dpInfo.Jarjar_rules = append(dpInfo.Jarjar_rules, j.expandJarjarRules.String())
|
dpInfo.Jarjar_rules = append(dpInfo.Jarjar_rules, j.expandJarjarRules.String())
|
||||||
|
dpInfo.Jars = append(dpInfo.Jars, j.headerJarFile.String())
|
||||||
|
} else {
|
||||||
|
dpInfo.Srcs = append(dpInfo.Srcs, j.expandIDEInfoCompiledSrcs...)
|
||||||
|
dpInfo.SrcJars = append(dpInfo.SrcJars, j.compiledSrcJars.Strings()...)
|
||||||
|
dpInfo.SrcJars = append(dpInfo.SrcJars, j.annoSrcJars.Strings()...)
|
||||||
}
|
}
|
||||||
|
dpInfo.Deps = append(dpInfo.Deps, j.CompilerDeps()...)
|
||||||
|
dpInfo.Aidl_include_dirs = append(dpInfo.Aidl_include_dirs, j.deviceProperties.Aidl.Include_dirs...)
|
||||||
dpInfo.Static_libs = append(dpInfo.Static_libs, j.properties.Static_libs...)
|
dpInfo.Static_libs = append(dpInfo.Static_libs, j.properties.Static_libs...)
|
||||||
dpInfo.Libs = append(dpInfo.Libs, j.properties.Libs...)
|
dpInfo.Libs = append(dpInfo.Libs, j.properties.Libs...)
|
||||||
dpInfo.SrcJars = append(dpInfo.SrcJars, j.annoSrcJars.Strings()...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) CompilerDeps() []string {
|
func (j *Module) CompilerDeps() []string {
|
||||||
|
@@ -91,16 +91,23 @@ func TestCollectJavaLibraryPropertiesAddAidlIncludeDirs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCollectJavaLibraryPropertiesAddJarjarRules(t *testing.T) {
|
func TestCollectJavaLibraryWithJarJarRules(t *testing.T) {
|
||||||
expected := "Jarjar_rules.txt"
|
ctx, _ := testJava(t,
|
||||||
module := LibraryFactory().(*Library)
|
`
|
||||||
module.expandJarjarRules = android.PathForTesting(expected)
|
java_library {
|
||||||
|
name: "javalib",
|
||||||
|
srcs: ["foo.java"],
|
||||||
|
jarjar_rules: "jarjar_rules.txt",
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
|
||||||
dpInfo := &android.IdeInfo{}
|
dpInfo := &android.IdeInfo{}
|
||||||
|
|
||||||
module.IDEInfo(dpInfo)
|
module.IDEInfo(dpInfo)
|
||||||
|
android.AssertBoolEquals(t, "IdeInfo.Srcs of repackaged library should be empty", true, len(dpInfo.Srcs) == 0)
|
||||||
if dpInfo.Jarjar_rules[0] != expected {
|
android.AssertStringEquals(t, "IdeInfo.Jar_rules of repackaged library should not be empty", "jarjar_rules.txt", dpInfo.Jarjar_rules[0])
|
||||||
t.Errorf("Library.IDEInfo() Jarjar_rules = %v, want %v", dpInfo.Jarjar_rules[0], expected)
|
if !android.SubstringInList(dpInfo.Jars, "soong/.intermediates/javalib/android_common/jarjar/turbine/javalib.jar") {
|
||||||
|
t.Errorf("IdeInfo.Jars of repackaged library should contain the output of jarjar-ing. All outputs: %v\n", dpInfo.Jars)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3602,3 +3602,19 @@ func (s *sdkLibrarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberCo
|
|||||||
propertySet.AddProperty("doctag_files", dests)
|
propertySet.AddProperty("doctag_files", dests)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(b/358613520): This can be removed when modules are no longer allowed to depend on the top-level library.
|
||||||
|
func (s *SdkLibrary) IDEInfo(dpInfo *android.IdeInfo) {
|
||||||
|
s.Library.IDEInfo(dpInfo)
|
||||||
|
if s.implLibraryModule != nil {
|
||||||
|
dpInfo.Deps = append(dpInfo.Deps, s.implLibraryModule.Name())
|
||||||
|
} else {
|
||||||
|
// This java_sdk_library does not have an implementation (it sets `api_only` to true).
|
||||||
|
// Examples of this are `art.module.intra.core.api` (IntraCore api surface).
|
||||||
|
// Return the "public" stubs for these.
|
||||||
|
stubPaths := s.findClosestScopePath(apiScopePublic)
|
||||||
|
if len(stubPaths.stubsHeaderPath) > 0 {
|
||||||
|
dpInfo.Jars = append(dpInfo.Jars, stubPaths.stubsHeaderPath[0].String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user