Use transitive header jars in classpaths
Skip combining jars into turbine-combined, combined, and withres jars
and instead collect transitive jars to use in the classpath and to
produce the final dexed jar.
This reduces the size of a `m checkbuild` in git_main by 11%, from
1300 KiB to 1154 KiB. It may also improve caching and reduce uplink
network bandwidth when building with RBE, as now the classpath inputs
to rules are themselves outputs of previous rules and so already in
the RBE CAS.
The downside is that the classpath inputs to each rule are now much
longer, increasing the Soong ninja file size 11%, from 4.6 GiB to
5.1 GiB. This could be mitigated in the future by supporting something
like depsets in the generated ninja file to reduce duplication.
Bug: 308016794
Test: TestSimple, TestKotlin, TestClasspath
Flag: build.RELEASE_USE_TRANSITIVE_JARS_IN_CLASSPATH
Change-Id: I2b7b4261375494370da70f98597c8719f1d561cf
diff --git a/java/sdk_test.go b/java/sdk_test.go
index 2dac27a..9bfe6a2 100644
--- a/java/sdk_test.go
+++ b/java/sdk_test.go
@@ -391,15 +391,19 @@
t.Parallel()
t.Run("basic", func(t *testing.T) {
t.Parallel()
- testClasspathTestCases(t, classpathTestcases, false)
+ testClasspathTestCases(t, classpathTestcases, false, false)
})
t.Run("Always_use_prebuilt_sdks=true", func(t *testing.T) {
- testClasspathTestCases(t, classpathTestcases, true)
+ testClasspathTestCases(t, classpathTestcases, true, false)
+ })
+
+ t.Run("UseTransitiveJarsInClasspath", func(t *testing.T) {
+ testClasspathTestCases(t, classpathTestcases, false, true)
})
}
-func testClasspathTestCases(t *testing.T, classpathTestcases []classpathTestCase, alwaysUsePrebuiltSdks bool) {
+func testClasspathTestCases(t *testing.T, classpathTestcases []classpathTestCase, alwaysUsePrebuiltSdks, useTransitiveJarsInClasspath bool) {
for _, testcase := range classpathTestcases {
if testcase.forAlwaysUsePrebuiltSdks != nil && *testcase.forAlwaysUsePrebuiltSdks != alwaysUsePrebuiltSdks {
continue
@@ -437,7 +441,14 @@
convertModulesToPaths := func(cp []string) []string {
ret := make([]string, len(cp))
for i, e := range cp {
- ret[i] = defaultModuleToPath(e)
+ switch {
+ case e == `""`, strings.HasSuffix(e, ".jar"):
+ ret[i] = e
+ case useTransitiveJarsInClasspath:
+ ret[i] = filepath.Join("out", "soong", ".intermediates", defaultJavaDir, e, "android_common", "turbine", e+".jar")
+ default:
+ ret[i] = filepath.Join("out", "soong", ".intermediates", defaultJavaDir, e, "android_common", "turbine-combined", e+".jar")
+ }
}
return ret
}
@@ -531,6 +542,9 @@
variables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
})
}
+ if useTransitiveJarsInClasspath {
+ preparer = PrepareForTestWithTransitiveClasspathEnabled
+ }
fixtureFactory := android.GroupFixturePreparers(
prepareForJavaTest,