summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--java/base.go14
-rw-r--r--java/java.go24
-rw-r--r--java/jdeps_test.go38
3 files changed, 62 insertions, 14 deletions
diff --git a/java/base.go b/java/base.go
index 02dc3e35b..be12ffd62 100644
--- a/java/base.go
+++ b/java/base.go
@@ -550,6 +550,10 @@ type Module struct {
// java_aconfig_library or java_library modules that are statically linked
// to this module. Does not contain cache files from all transitive dependencies.
aconfigCacheFiles android.Paths
+
+ // List of soong module dependencies required to compile the current module.
+ // This information is printed out to `Dependencies` field in module_bp_java_deps.json
+ compileDepNames []string
}
var _ android.InstallableModule = (*Module)(nil)
@@ -2061,10 +2065,7 @@ func (j *Module) IDEInfo(dpInfo *android.IdeInfo) {
}
func (j *Module) CompilerDeps() []string {
- jdeps := []string{}
- jdeps = append(jdeps, j.properties.Libs...)
- jdeps = append(jdeps, j.properties.Static_libs...)
- return jdeps
+ return j.compileDepNames
}
func (j *Module) hasCode(ctx android.ModuleContext) bool {
@@ -2408,6 +2409,11 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
}
}
+ if android.InList(tag, compileDependencyTags) {
+ // Add the dependency name to compileDepNames so that it can be recorded in module_bp_java_deps.json
+ j.compileDepNames = append(j.compileDepNames, otherName)
+ }
+
addCLCFromDep(ctx, module, j.classLoaderContexts)
addMissingOptionalUsesLibsFromDep(ctx, module, &j.usesLibrary)
})
diff --git a/java/java.go b/java/java.go
index 498b53939..3dae4e42b 100644
--- a/java/java.go
+++ b/java/java.go
@@ -443,6 +443,30 @@ var (
usesLibCompat30OptTag = makeUsesLibraryDependencyTag(30, true)
)
+// A list of tags for deps used for compiling a module.
+// Any dependency tags that modifies the following properties of `deps` in `Module.collectDeps` should be
+// added to this list:
+// - bootClasspath
+// - classpath
+// - java9Classpath
+// - systemModules
+// - kotlin deps...
+var (
+ compileDependencyTags = []blueprint.DependencyTag{
+ sdkLibTag,
+ libTag,
+ staticLibTag,
+ bootClasspathTag,
+ systemModulesTag,
+ java9LibTag,
+ kotlinStdlibTag,
+ kotlinAnnotationsTag,
+ kotlinPluginTag,
+ syspropPublicStubDepTag,
+ instrumentationForTag,
+ }
+)
+
func IsLibDepTag(depTag blueprint.DependencyTag) bool {
return depTag == libTag || depTag == sdkLibTag
}
diff --git a/java/jdeps_test.go b/java/jdeps_test.go
index 874d1d7c0..e1802243c 100644
--- a/java/jdeps_test.go
+++ b/java/jdeps_test.go
@@ -22,28 +22,46 @@ import (
)
func TestCollectJavaLibraryPropertiesAddLibsDeps(t *testing.T) {
- expected := []string{"Foo", "Bar"}
- module := LibraryFactory().(*Library)
- module.properties.Libs = append(module.properties.Libs, expected...)
+ ctx, _ := testJava(t,
+ `
+ java_library {name: "Foo"}
+ java_library {name: "Bar"}
+ java_library {
+ name: "javalib",
+ libs: ["Foo", "Bar"],
+ }
+ `)
+ module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
dpInfo := &android.IdeInfo{}
module.IDEInfo(dpInfo)
- if !reflect.DeepEqual(dpInfo.Deps, expected) {
- t.Errorf("Library.IDEInfo() Deps = %v, want %v", dpInfo.Deps, expected)
+ for _, expected := range []string{"Foo", "Bar"} {
+ if !android.InList(expected, dpInfo.Deps) {
+ t.Errorf("Library.IDEInfo() Deps = %v, %v not found", dpInfo.Deps, expected)
+ }
}
}
func TestCollectJavaLibraryPropertiesAddStaticLibsDeps(t *testing.T) {
- expected := []string{"Foo", "Bar"}
- module := LibraryFactory().(*Library)
- module.properties.Static_libs = append(module.properties.Static_libs, expected...)
+ ctx, _ := testJava(t,
+ `
+ java_library {name: "Foo"}
+ java_library {name: "Bar"}
+ java_library {
+ name: "javalib",
+ static_libs: ["Foo", "Bar"],
+ }
+ `)
+ module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
dpInfo := &android.IdeInfo{}
module.IDEInfo(dpInfo)
- if !reflect.DeepEqual(dpInfo.Deps, expected) {
- t.Errorf("Library.IDEInfo() Deps = %v, want %v", dpInfo.Deps, expected)
+ for _, expected := range []string{"Foo", "Bar"} {
+ if !android.InList(expected, dpInfo.Deps) {
+ t.Errorf("Library.IDEInfo() Deps = %v, %v not found", dpInfo.Deps, expected)
+ }
}
}