summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
author Jihoon Kang <jihoonkang@google.com> 2024-07-01 17:04:46 +0000
committer Jihoon Kang <jihoonkang@google.com> 2024-08-29 17:55:00 +0000
commit85bc19380567dfee327f04162587633673e3dcf7 (patch)
tree49f62c495320605e5f5792d702ea368adc8dc7f7 /java
parenta1527e5e23a517911891074a6b83dfe02823aef3 (diff)
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
Diffstat (limited to 'java')
-rw-r--r--java/base.go7
-rw-r--r--java/core-libraries/Android.bp4
-rw-r--r--java/dexpreopt_test.go13
-rw-r--r--java/sdk_library.go1
-rw-r--r--java/testing.go8
5 files changed, 30 insertions, 3 deletions
diff --git a/java/base.go b/java/base.go
index 4cd60215c..e516891a3 100644
--- a/java/base.go
+++ b/java/base.go
@@ -593,6 +593,13 @@ func (j *Module) InstallInProduct() bool {
return j.ProductSpecific()
}
+var _ android.StubsAvailableModule = (*Module)(nil)
+
+// To safisfy the StubsAvailableModule interface
+func (j *Module) IsStubsModule() bool {
+ return proptools.Bool(j.properties.Is_stubs_module)
+}
+
func (j *Module) CheckStableSdkVersion(ctx android.BaseModuleContext) error {
sdkVersion := j.SdkVersion(ctx)
if sdkVersion.Stable() {
diff --git a/java/core-libraries/Android.bp b/java/core-libraries/Android.bp
index cee7a192e..1cca7ad49 100644
--- a/java/core-libraries/Android.bp
+++ b/java/core-libraries/Android.bp
@@ -38,6 +38,7 @@ java_defaults {
visibility: ["//visibility:public"],
sdk_version: "none",
system_modules: "none",
+ is_stubs_module: true,
}
java_library {
@@ -289,6 +290,7 @@ java_defaults {
sdk_version: "none",
system_modules: "none",
patch_module: "java.base",
+ is_stubs_module: true,
}
// Same as legacy.core.platform.api.stubs, but android annotations are
@@ -307,6 +309,7 @@ java_library {
"legacy.core.platform.api.stubs",
],
patch_module: "java.base",
+ is_stubs_module: true,
}
java_library {
@@ -339,6 +342,7 @@ java_library {
"stable.core.platform.api.stubs",
],
patch_module: "java.base",
+ is_stubs_module: true,
}
// Used when compiling higher-level code against *.core.platform.api.stubs.
diff --git a/java/dexpreopt_test.go b/java/dexpreopt_test.go
index 73e33f4fb..07d0595e6 100644
--- a/java/dexpreopt_test.go
+++ b/java/dexpreopt_test.go
@@ -54,6 +54,7 @@ func TestDexpreoptEnabled(t *testing.T) {
name: "foo",
installable: true,
srcs: ["a.java"],
+ sdk_version: "current",
}`,
enabled: true,
},
@@ -98,6 +99,7 @@ func TestDexpreoptEnabled(t *testing.T) {
java_library {
name: "foo",
installable: true,
+ sdk_version: "current",
}`,
enabled: false,
},
@@ -107,6 +109,7 @@ func TestDexpreoptEnabled(t *testing.T) {
java_library {
name: "foo",
srcs: ["a.java"],
+ sdk_version: "current",
}`,
enabled: false,
},
@@ -144,6 +147,7 @@ func TestDexpreoptEnabled(t *testing.T) {
name: "foo",
srcs: ["a.java"],
compile_dex: true,
+ sdk_version: "current",
}`,
enabled: false,
},
@@ -164,6 +168,7 @@ func TestDexpreoptEnabled(t *testing.T) {
installable: true,
srcs: ["a.java"],
apex_available: ["com.android.apex1"],
+ sdk_version: "current",
}`,
apexVariant: true,
enabled: false,
@@ -176,6 +181,7 @@ func TestDexpreoptEnabled(t *testing.T) {
installable: true,
srcs: ["a.java"],
apex_available: ["com.android.apex1"],
+ sdk_version: "current",
}`,
moduleName: "service-foo",
apexVariant: true,
@@ -189,6 +195,7 @@ func TestDexpreoptEnabled(t *testing.T) {
installable: true,
srcs: ["a.java"],
apex_available: ["com.android.apex1"],
+ sdk_version: "current",
}`,
moduleName: "prebuilt_service-foo",
apexVariant: true,
@@ -202,6 +209,7 @@ func TestDexpreoptEnabled(t *testing.T) {
installable: true,
srcs: ["a.java"],
apex_available: ["com.android.apex1"],
+ sdk_version: "current",
}`,
moduleName: "service-foo",
apexVariant: false,
@@ -311,6 +319,7 @@ func TestDexpreoptBuiltInstalledForApex(t *testing.T) {
installable: true,
srcs: ["a.java"],
apex_available: ["com.android.apex1"],
+ sdk_version: "current",
}`)
ctx := result.TestContext
module := ctx.ModuleForTests("service-foo", "android_common_apex1000")
@@ -342,6 +351,7 @@ func TestDexpreoptBuiltInstalledForApex(t *testing.T) {
name: "foo",
installable: true,
srcs: ["a.java"],
+ sdk_version: "current",
}`)
ctx = result.TestContext
module = ctx.ModuleForTests("foo", "android_common")
@@ -398,6 +408,7 @@ func TestAndroidMkEntriesForApex(t *testing.T) {
installable: true,
srcs: ["a.java"],
apex_available: ["com.android.apex1"],
+ sdk_version: "current",
}`)
ctx := result.TestContext
module := ctx.ModuleForTests("service-foo", "android_common_apex1000")
@@ -429,6 +440,7 @@ func TestAndroidMkEntriesForApex(t *testing.T) {
name: "foo",
installable: true,
srcs: ["a.java"],
+ sdk_version: "current",
}`)
ctx = result.TestContext
module = ctx.ModuleForTests("foo", "android_common")
@@ -454,6 +466,7 @@ func TestGenerateProfileEvenIfDexpreoptIsDisabled(t *testing.T) {
profile: "art-profile",
},
srcs: ["a.java"],
+ sdk_version: "current",
}`)
ctx := result.TestContext
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 25317c50d..a7a254af8 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -2099,6 +2099,7 @@ func (module *SdkLibrary) topLevelStubsLibraryProps(mctx android.DefaultableHook
props.Dist.Dir = proptools.StringPtr(module.apiDistPath(apiScope))
props.Dist.Tag = proptools.StringPtr(".jar")
}
+ props.Is_stubs_module = proptools.BoolPtr(true)
return props
}
diff --git a/java/testing.go b/java/testing.go
index 0e85022ce..03dcee667 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -184,6 +184,10 @@ var PrepareForTestWithJacocoInstrumentation = android.GroupFixturePreparers(
host_supported: true,
srcs: ["Test.java"],
sdk_version: "current",
+ apex_available: [
+ "//apex_available:anyapex",
+ "//apex_available:platform",
+ ],
}
`)),
)
@@ -408,7 +412,6 @@ func gatherRequiredDepsForTest() string {
"core.current.stubs",
"legacy.core.platform.api.stubs",
"stable.core.platform.api.stubs",
-
"android_stubs_current_exportable",
"android_system_stubs_current_exportable",
"android_test_stubs_current_exportable",
@@ -416,13 +419,11 @@ func gatherRequiredDepsForTest() string {
"android_system_server_stubs_current_exportable",
"core.current.stubs.exportable",
"legacy.core.platform.api.stubs.exportable",
-
"kotlin-stdlib",
"kotlin-stdlib-jdk7",
"kotlin-stdlib-jdk8",
"kotlin-annotations",
"stub-annotations",
-
"aconfig-annotations-lib",
"unsupportedappusage",
}
@@ -435,6 +436,7 @@ func gatherRequiredDepsForTest() string {
sdk_version: "none",
system_modules: "stable-core-platform-api-stubs-system-modules",
compile_dex: true,
+ is_stubs_module: true,
}
`, extra)
}