Introduce "Exclude_static_libs" property for Java modules

Exclude_static_libs property can be used to specify static libs that
should not be used to build the module. The list acts as filter for
static_libs.

Bug: 285410821
Test: go test ./java
Change-Id: Iee7f160ba88b5f64bdd265c30d47c9f51feb0f5e
This commit is contained in:
Jihoon Kang
2023-06-01 22:17:32 +00:00
parent f508c252bb
commit 381c2fa27c
4 changed files with 66 additions and 3 deletions

View File

@@ -59,6 +59,7 @@ func init() {
AddNeverAllowRules(createProhibitFrameworkAccessRules()...)
AddNeverAllowRules(createBp2BuildRule())
AddNeverAllowRules(createCcStubsRule())
AddNeverAllowRules(createJavaExcludeStaticLibsRule())
}
// Add a NeverAllow rule to the set of rules to apply.
@@ -253,6 +254,14 @@ func createProhibitFrameworkAccessRules() []Rule {
}
}
func createJavaExcludeStaticLibsRule() Rule {
return NeverAllow().
NotIn("build/soong").
ModuleType("java_library").
WithMatcher("exclude_static_libs", isSetMatcherInstance).
Because("exclude_static_libs property is only allowed for java modules defined in build/soong")
}
func neverallowMutator(ctx BottomUpMutatorContext) {
m, ok := ctx.Module().(Module)
if !ok {