Revert "Revert "Include proguard flag files from transitive java_library deps""
This reverts commit 6f7e288fb5ea2fb01d9093fd57081a82c09a6618.
Reason for revert: Downstream proguard usage has been fixed.
Change-Id: I3667e7e908eebc62c640b42cb96b04993fc66e45
diff --git a/java/dex_test.go b/java/dex_test.go
index 6617873..fc6cd0f 100644
--- a/java/dex_test.go
+++ b/java/dex_test.go
@@ -155,3 +155,57 @@
android.AssertStringDoesNotContain(t, "expected no static_lib header jar in foo javac classpath",
fooD8.Args["d8Flags"], staticLibHeader.String())
}
+
+func TestProguardFlagsInheritance(t *testing.T) {
+ result := PrepareForTestWithJavaDefaultModulesWithoutFakeDex2oatd.RunTestWithBp(t, `
+ android_app {
+ name: "app",
+ static_libs: [
+ "primary_android_lib",
+ "primary_lib",
+ ],
+ platform_apis: true,
+ }
+
+ java_library {
+ name: "primary_lib",
+ optimize: {
+ proguard_flags_files: ["primary.flags"],
+ },
+ }
+
+ android_library {
+ name: "primary_android_lib",
+ static_libs: ["secondary_lib"],
+ optimize: {
+ proguard_flags_files: ["primary_android.flags"],
+ },
+ }
+
+ java_library {
+ name: "secondary_lib",
+ static_libs: ["tertiary_lib"],
+ optimize: {
+ proguard_flags_files: ["secondary.flags"],
+ },
+ }
+
+ java_library {
+ name: "tertiary_lib",
+ optimize: {
+ proguard_flags_files: ["tertiary.flags"],
+ },
+ }
+ `)
+
+ app := result.ModuleForTests("app", "android_common")
+ appR8 := app.Rule("r8")
+ android.AssertStringDoesContain(t, "expected primary_lib's proguard flags from direct dep",
+ appR8.Args["r8Flags"], "primary.flags")
+ android.AssertStringDoesContain(t, "expected primary_android_lib's proguard flags from direct dep",
+ appR8.Args["r8Flags"], "primary_android.flags")
+ android.AssertStringDoesContain(t, "expected secondary_lib's proguard flags from inherited dep",
+ appR8.Args["r8Flags"], "secondary.flags")
+ android.AssertStringDoesContain(t, "expected tertiary_lib's proguard flags from inherited dep",
+ appR8.Args["r8Flags"], "tertiary.flags")
+}