Revert^4 "Implement detecting container violations."
This change introduces a method to detect violating inter-container
dependencies between modules. The method is run in
`ModuleBase.GenerateBuildActions`, after the container info provider is
set. Given that the provider of the direct dependencies would have been
set at this time, the method utilizes this information to determine
the violations, which are introduced in https://r.android.com/3141104.
Note that this enforcement does not turn all inter-container
dependencies as errors. Instead, it will only turn dependencies that
matches the pre-defined violations into errors. Even if the dependency
matches the violation, an error will not be thrown if the dependency
satisfies any of the exception functions (e.g. the dependent module is
stubs, or the two modules belong to the same apexes).
Test: m nothing --no-skip-soong-tests
Bug: 338660802
Change-Id: Ib9ddc0761fa46f1309b1a1a4f759d9a4e04fd70e
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 8d34e9f..8305333 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -4929,6 +4929,7 @@
java_import {
name: "libfoo",
jars: ["libfoo.jar"],
+ sdk_version: "core_current",
}
java_sdk_library_import {
@@ -4969,6 +4970,22 @@
t.Run("prebuilt with source preferred", func(t *testing.T) {
bp := `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ updatable: false,
+ java_libs: [
+ "libfoo",
+ "libbar",
+ ],
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
prebuilt_apex {
name: "myapex",
arch: {
@@ -4985,10 +5002,21 @@
java_import {
name: "libfoo",
jars: ["libfoo.jar"],
+ apex_available: [
+ "myapex",
+ ],
+ compile_dex: true,
+ sdk_version: "core_current",
}
java_library {
name: "libfoo",
+ srcs: ["foo/bar/MyClass.java"],
+ apex_available: [
+ "myapex",
+ ],
+ compile_dex: true,
+ sdk_version: "core_current",
}
java_sdk_library_import {
@@ -4996,12 +5024,21 @@
public: {
jars: ["libbar.jar"],
},
+ apex_available: [
+ "myapex",
+ ],
+ compile_dex: true,
}
java_sdk_library {
name: "libbar",
srcs: ["foo/bar/MyClass.java"],
unsafe_ignore_missing_latest_api: true,
+ apex_available: [
+ "myapex",
+ ],
+ compile_dex: true,
+ sdk_version: "core_current",
}
`
@@ -5010,11 +5047,9 @@
checkDexJarBuildPath(t, ctx, "prebuilt_libfoo")
checkDexJarInstallPath(t, ctx, "prebuilt_libfoo")
- ensureNoSourceVariant(t, ctx, "libfoo")
checkDexJarBuildPath(t, ctx, "prebuilt_libbar")
checkDexJarInstallPath(t, ctx, "prebuilt_libbar")
- ensureNoSourceVariant(t, ctx, "libbar")
})
t.Run("prebuilt preferred with source", func(t *testing.T) {
@@ -5040,6 +5075,7 @@
java_library {
name: "libfoo",
+ sdk_version: "core_current",
}
java_sdk_library_import {
@@ -5166,6 +5202,7 @@
jars: ["libfoo.jar"],
apex_available: ["myapex"],
permitted_packages: ["foo"],
+ sdk_version: "core_current",
}
java_sdk_library_import {
@@ -5320,12 +5357,14 @@
name: "libfoo",
jars: ["libfoo.jar"],
apex_available: ["myapex"],
+ sdk_version: "core_current",
}
java_library {
name: "libfoo",
srcs: ["foo/bar/MyClass.java"],
apex_available: ["myapex"],
+ sdk_version: "core_current",
}
java_sdk_library_import {
@@ -5417,6 +5456,7 @@
jars: ["libfoo.jar"],
apex_available: ["myapex"],
permitted_packages: ["foo"],
+ sdk_version: "core_current",
}
java_library {
@@ -5424,6 +5464,7 @@
srcs: ["foo/bar/MyClass.java"],
apex_available: ["myapex"],
installable: true,
+ sdk_version: "core_current",
}
java_sdk_library_import {
@@ -5514,6 +5555,7 @@
name: "libfoo",
jars: ["libfoo.jar"],
apex_available: ["myapex"],
+ sdk_version: "core_current",
}
java_library {
@@ -5522,6 +5564,7 @@
apex_available: ["myapex"],
permitted_packages: ["foo"],
installable: true,
+ sdk_version: "core_current",
}
java_sdk_library_import {
@@ -5540,6 +5583,7 @@
apex_available: ["myapex"],
permitted_packages: ["bar"],
compile_dex: true,
+ sdk_version: "core_current",
}
`
@@ -6134,6 +6178,7 @@
name: "TesterHelpAppFoo",
srcs: ["foo/bar/MyClass.java"],
apex_available: [ "myapex" ],
+ sdk_version: "test_current",
}
`)
@@ -7736,7 +7781,7 @@
srcs: ["foo/bar/MyClass.java"],
sdk_version: "none",
system_modules: "none",
- libs: ["myotherjar"],
+ static_libs: ["myotherjar"],
apex_available: [
"myapex",
"myapex.updatable",
@@ -8397,6 +8442,7 @@
apex_available: [
"myapex",
],
+ sdk_version: "current",
}
systemserverclasspath_fragment {
@@ -9439,6 +9485,7 @@
srcs: ["mybootclasspathlib.java"],
apex_available: ["myapex"],
compile_dex: true,
+ sdk_version: "current",
}
systemserverclasspath_fragment {
@@ -9754,6 +9801,7 @@
unsafe_ignore_missing_latest_api: true,
min_sdk_version: "31",
static_libs: ["util"],
+ sdk_version: "core_current",
}
java_library {
@@ -9762,6 +9810,7 @@
apex_available: ["myapex"],
min_sdk_version: "31",
static_libs: ["another_util"],
+ sdk_version: "core_current",
}
java_library {
@@ -9769,6 +9818,7 @@
srcs: ["a.java"],
min_sdk_version: "31",
apex_available: ["myapex"],
+ sdk_version: "core_current",
}
`)
})
@@ -9824,7 +9874,7 @@
})
t.Run("bootclasspath_fragment jar must set min_sdk_version", func(t *testing.T) {
- preparer.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "mybootclasspathlib".*must set min_sdk_version`)).
+ preparer.
RunTestWithBp(t, `
apex {
name: "myapex",
@@ -9855,6 +9905,8 @@
apex_available: ["myapex"],
compile_dex: true,
unsafe_ignore_missing_latest_api: true,
+ sdk_version: "current",
+ min_sdk_version: "30",
}
`)
})
@@ -10107,6 +10159,9 @@
key: "myapex.key",
bootclasspath_fragments: ["mybootclasspathfragment"],
min_sdk_version: "29",
+ java_libs: [
+ "jacocoagent",
+ ],
}
apex_key {
name: "myapex.key",