Add support for android_library modules
Add support for compiling android_library modules into AARs,
and refactor app support on top of it.
Bug: 73724997
Test: app_test.go
Change-Id: I1dfac5fffe577c6680bc4709147b2061eb7d819c
diff --git a/java/app_test.go b/java/app_test.go
index ba017a1..7a61771 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -59,41 +59,44 @@
}
func TestApp(t *testing.T) {
- ctx := testApp(t, `
- android_app {
- name: "foo",
- srcs: ["a.java"],
- }
- `)
+ for _, moduleType := range []string{"android_app", "android_library"} {
+ t.Run(moduleType, func(t *testing.T) {
+ ctx := testApp(t, moduleType+` {
+ name: "foo",
+ srcs: ["a.java"],
+ }
+ `)
- foo := ctx.ModuleForTests("foo", "android_common")
+ foo := ctx.ModuleForTests("foo", "android_common")
- expectedLinkImplicits := []string{"AndroidManifest.xml"}
+ expectedLinkImplicits := []string{"AndroidManifest.xml"}
- frameworkRes := ctx.ModuleForTests("framework-res", "android_common")
- expectedLinkImplicits = append(expectedLinkImplicits,
- frameworkRes.Output("package-res.apk").Output.String())
+ frameworkRes := ctx.ModuleForTests("framework-res", "android_common")
+ expectedLinkImplicits = append(expectedLinkImplicits,
+ frameworkRes.Output("package-res.apk").Output.String())
- // Test the mapping from input files to compiled output file names
- compile := foo.Output(compiledResourceFiles[0])
- if !reflect.DeepEqual(resourceFiles, compile.Inputs.Strings()) {
- t.Errorf("expected aapt2 compile inputs expected:\n %#v\n got:\n %#v",
- resourceFiles, compile.Inputs.Strings())
- }
+ // Test the mapping from input files to compiled output file names
+ compile := foo.Output(compiledResourceFiles[0])
+ if !reflect.DeepEqual(resourceFiles, compile.Inputs.Strings()) {
+ t.Errorf("expected aapt2 compile inputs expected:\n %#v\n got:\n %#v",
+ resourceFiles, compile.Inputs.Strings())
+ }
- compiledResourceOutputs := compile.Outputs.Strings()
- sort.Strings(compiledResourceOutputs)
+ compiledResourceOutputs := compile.Outputs.Strings()
+ sort.Strings(compiledResourceOutputs)
- expectedLinkImplicits = append(expectedLinkImplicits, compiledResourceOutputs...)
+ expectedLinkImplicits = append(expectedLinkImplicits, compiledResourceOutputs...)
- list := foo.Output("aapt2/res.list")
- expectedLinkImplicits = append(expectedLinkImplicits, list.Output.String())
+ list := foo.Output("aapt2/res.list")
+ expectedLinkImplicits = append(expectedLinkImplicits, list.Output.String())
- // Check that the link rule uses
- res := ctx.ModuleForTests("foo", "android_common").Output("package-res.apk")
- if !reflect.DeepEqual(expectedLinkImplicits, res.Implicits.Strings()) {
- t.Errorf("expected aapt2 link implicits expected:\n %#v\n got:\n %#v",
- expectedLinkImplicits, res.Implicits.Strings())
+ // Check that the link rule uses
+ res := ctx.ModuleForTests("foo", "android_common").Output("package-res.apk")
+ if !reflect.DeepEqual(expectedLinkImplicits, res.Implicits.Strings()) {
+ t.Errorf("expected aapt2 link implicits expected:\n %#v\n got:\n %#v",
+ expectedLinkImplicits, res.Implicits.Strings())
+ }
+ })
}
}