summaryrefslogtreecommitdiff
path: root/java/sdk_test.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2024-07-26 15:25:46 -0700
committer Colin Cross <ccross@android.com> 2024-09-04 16:13:46 -0700
commitc9b4f6b502ec2029196d658d06eabdf1dc555770 (patch)
tree88c12fa95c37d7e06b9cedc93418c5079ac949ac /java/sdk_test.go
parentfdaa672ad1faacf0fb279adf876841dc2ffb404e (diff)
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
Diffstat (limited to 'java/sdk_test.go')
-rw-r--r--java/sdk_test.go22
1 files changed, 18 insertions, 4 deletions
diff --git a/java/sdk_test.go b/java/sdk_test.go
index 2dac27af1..9bfe6a2b5 100644
--- a/java/sdk_test.go
+++ b/java/sdk_test.go
@@ -391,15 +391,19 @@ func TestClasspath(t *testing.T) {
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 @@ func testClasspathTestCases(t *testing.T, classpathTestcases []classpathTestCase
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 @@ func testClasspathTestCases(t *testing.T, classpathTestcases []classpathTestCase
variables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
})
}
+ if useTransitiveJarsInClasspath {
+ preparer = PrepareForTestWithTransitiveClasspathEnabled
+ }
fixtureFactory := android.GroupFixturePreparers(
prepareForJavaTest,