From d967aee96fca945b550ca4ba9026ec93fed7cb39 Mon Sep 17 00:00:00 2001 From: Andrei Onea Date: Wed, 19 Jan 2022 15:36:40 +0000 Subject: [PATCH] Improve apex build check explanation Discourage jarjaring code where there are alternatives with better system health implications. Test: m Bug: 215233995 Change-Id: I1b076d00e1ad6aa32b41da6bda1033978b5e829d --- apex/apex.go | 11 +++++++++-- apex/apex_test.go | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index 635ff30a3..09e634e82 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -3204,8 +3204,15 @@ func createApexPermittedPackagesRules(modules_packages map[string][]string) []an WithMatcher("permitted_packages", android.NotInList(module_packages)). WithMatcher("min_sdk_version", android.LessThanSdkVersion("Tiramisu")). Because("jars that are part of the " + module_name + - " module may only allow these packages: " + strings.Join(module_packages, ",") + - " with min_sdk < T. Please jarjar or move code around.") + " module may only use these package prefixes: " + strings.Join(module_packages, ",") + + " with min_sdk < T. Please consider the following alternatives:\n" + + " 1. If the offending code is from a statically linked library, consider " + + "removing that dependency and using an alternative already in the " + + "bootclasspath, or perhaps a shared library." + + " 2. Move the offending code into an allowed package.\n" + + " 3. Jarjar the offending code. Please be mindful of the potential system " + + "health implications of bundling that code, particularly if the offending jar " + + "is part of the bootclasspath.") rules = append(rules, permittedPackagesRule) } return rules diff --git a/apex/apex_test.go b/apex/apex_test.go index 727a1f2ec..9a6fae3c3 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -7457,7 +7457,7 @@ func TestApexPermittedPackagesRules(t *testing.T) { }, { name: "Bootclasspath apex jar not satisfying allowed module packages on Q.", - expectedError: `(?s)module "bcp_lib2" .* which is restricted because jars that are part of the myapex module may only allow these packages: foo.bar with min_sdk < T. Please jarjar or move code around.`, + expectedError: `(?s)module "bcp_lib2" .* which is restricted because jars that are part of the myapex module may only use these package prefixes: foo.bar with min_sdk < T. Please consider the following alternatives:\n 1. If the offending code is from a statically linked library, consider removing that dependency and using an alternative already in the bootclasspath, or perhaps a shared library. 2. Move the offending code into an allowed package.\n 3. Jarjar the offending code. Please be mindful of the potential system health implications of bundling that code, particularly if the offending jar is part of the bootclasspath.`, bp: ` java_library { name: "bcp_lib1", @@ -7494,7 +7494,7 @@ func TestApexPermittedPackagesRules(t *testing.T) { }, { name: "Bootclasspath apex jar not satisfying allowed module packages on R.", - expectedError: `(?s)module "bcp_lib2" .* which is restricted because jars that are part of the myapex module may only allow these packages: foo.bar with min_sdk < T. Please jarjar or move code around.`, + expectedError: `(?s)module "bcp_lib2" .* which is restricted because jars that are part of the myapex module may only use these package prefixes: foo.bar with min_sdk < T. Please consider the following alternatives:\n 1. If the offending code is from a statically linked library, consider removing that dependency and using an alternative already in the bootclasspath, or perhaps a shared library. 2. Move the offending code into an allowed package.\n 3. Jarjar the offending code. Please be mindful of the potential system health implications of bundling that code, particularly if the offending jar is part of the bootclasspath.`, bp: ` java_library { name: "bcp_lib1",