From 25f35fa650eac1c4890f908359af1f1dba8d1c15 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 30 Apr 2019 13:13:39 +0100 Subject: [PATCH] Remove unnecessary core library neverallow rules The rules that restricted access to core library targets are no longer required as they have been replaced with visibility rules. The visibility rules are safer because they check all dependencies whereas the neverallow rules that have been removed only checked dependencies in the libs property and so missed dependencies in static_libs and java_libs properties. Bug: 112158820 Test: m core-tests Change-Id: Ibfef74db0769992266ebadf445836d2a183df3f7 Merged-In: Ibfef74db0769992266ebadf445836d2a183df3f7 (cherry picked from commit 8e8c01c3825a615940ee7f9e097130ebe43c26de) --- android/neverallow.go | 23 +++-------------------- android/neverallow_test.go | 11 ----------- 2 files changed, 3 insertions(+), 31 deletions(-) diff --git a/android/neverallow.go b/android/neverallow.go index 50fbe5e89..abe25e6f2 100644 --- a/android/neverallow.go +++ b/android/neverallow.go @@ -98,32 +98,15 @@ func createLibcoreRules() []*rule { "external/wycheproof", } - var coreModules = []string{ - "core-all", - "core-oj", - "core-libart", - "okhttp", - "bouncycastle", - "conscrypt", - "apache-xml", - } - - // Core library constraints. Prevent targets adding dependencies on core - // library internals, which could lead to compatibility issues with the ART - // mainline module. They should use core.platform.api.stubs instead. + // Core library constraints. The no_standard_libs can only be used in core + // library projects. Access to core library targets is restricted using + // visibility rules. rules := []*rule{ neverallow(). notIn(append(coreLibraryProjects, "development")...). with("no_standard_libs", "true"), } - for _, m := range coreModules { - r := neverallow(). - notIn(coreLibraryProjects...). - with("libs", m). - because("Only core libraries projects can depend on " + m) - rules = append(rules, r) - } return rules } diff --git a/android/neverallow_test.go b/android/neverallow_test.go index 5451620ff..ab47808d2 100644 --- a/android/neverallow_test.go +++ b/android/neverallow_test.go @@ -137,17 +137,6 @@ var neverallowTests = []struct { }, expectedError: "", }, - { - name: "dependency on core-libart", - fs: map[string][]byte{ - "Blueprints": []byte(` - java_library { - name: "needs_core_libart", - libs: ["core-libart"], - }`), - }, - expectedError: "Only core libraries projects can depend on core-libart", - }, { name: "dependency on updatable-media", fs: map[string][]byte{