diff options
author | 2024-08-09 17:37:25 +0000 | |
---|---|---|
committer | 2024-08-09 22:27:47 +0000 | |
commit | dee1a7419f6d28451500a3e2a9b49440fce4c8f9 (patch) | |
tree | fce2b3b469f9b92d79666f45c168ed7ef76979a2 /java/sdk_library.go | |
parent | 6e8bd1cc371f9e37ab81ed7ed3f3f4e129e476d4 (diff) |
Add .internal modules to IDEInfo.deps of top-level java_sdk_library
libraries and apps can depend on the top-level java_sdk_library like
such
```
java_library {
name: "mylib",
libs: ["somesdklib"],
}
```
and soong will automatically resolve mylib's classpath to either the
stub or impl library based on the api container these libraries are in.
Since the top-level java_sdk_library has no compilation actions, code
completion of `mylib` is not feasible today via
`module_bp_java_deps.json`. This CL adds support for this code
completion by registering the .impl (or public stubs) as a transtive
dependency of `mylib`.
The implication of this change is that implementation symbols of the sdk
library will be surfaced during code-completion of mylib, even when
mylib is in a different container. Long term, this should go away when
all the library dependencies are made explicit in Android.bp files.
Test: go build ./java
Test: verified that symbols of android.car.builtin (a java_sdk_library)
can be resolved with the repro instructions in b/356572093#comment5
Bug: 356572093
Bug: 358613520
Change-Id: Ia3887bae34bbd25b8c6346f43602835da32af84a
Diffstat (limited to 'java/sdk_library.go')
-rw-r--r-- | java/sdk_library.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/java/sdk_library.go b/java/sdk_library.go index a8cc1b81f..4f95a997d 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -3602,3 +3602,19 @@ func (s *sdkLibrarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberCo 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()) + } + } +} |