From fd620b2b448bd68c7cb507cfbae0bae268dd0b5e Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 23 Feb 2024 10:05:21 -0800 Subject: [PATCH] Put extraCombinedJars after the compiled jars extraCombinedJars contains the R.jar generated by ResourceProcessorBusyBox for apps. It needs to go before any static_libs dependencies so that the finalized R values take precedence over any non-final R values that may have been included in the dependencies. Moving after the javac and kotlinc compiled jars helps minimize differences when turning on use_resource_processor by default by using the MANIFEST.MF generated by soong_zip instead of the one generated by ResourceProcessorBusyBox, which contains a different Created-By field. Bug: 294256649 Test: m javac-check Change-Id: I8d060594404121fd36ef650ac317f0c5d5f92b23 --- java/app_test.go | 4 ++-- java/base.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/java/app_test.go b/java/app_test.go index 362bef922..2bd3cebc6 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -931,8 +931,8 @@ func TestAndroidResourceProcessor(t *testing.T) { "out/soong/.intermediates/direct_import/android_common/aar/classes-combined.jar", }, appCombined: []string{ - "out/soong/.intermediates/app/android_common/busybox/R.jar", "out/soong/.intermediates/app/android_common/javac/app.jar", + "out/soong/.intermediates/app/android_common/busybox/R.jar", "out/soong/.intermediates/direct/android_common/combined/direct.jar", "out/soong/.intermediates/direct_import/android_common/aar/classes-combined.jar", }, @@ -1037,8 +1037,8 @@ func TestAndroidResourceProcessor(t *testing.T) { "out/soong/.intermediates/direct_import/android_common/aar/classes-combined.jar", }, appCombined: []string{ - "out/soong/.intermediates/app/android_common/busybox/R.jar", "out/soong/.intermediates/app/android_common/javac/app.jar", + "out/soong/.intermediates/app/android_common/busybox/R.jar", "out/soong/.intermediates/direct/android_common/combined/direct.jar", "out/soong/.intermediates/direct_import/android_common/aar/classes-combined.jar", }, diff --git a/java/base.go b/java/base.go index 284ec9918..f10310eb8 100644 --- a/java/base.go +++ b/java/base.go @@ -1296,7 +1296,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath } } - jars := append(android.Paths(nil), kotlinJars...) + jars := slices.Clone(kotlinJars) j.compiledSrcJars = srcJars @@ -1311,7 +1311,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath // allow for the use of annotation processors that do function correctly // with sharding enabled. See: b/77284273. } - extraJars := append(android.CopyOf(extraCombinedJars), kotlinHeaderJars...) + extraJars := append(slices.Clone(kotlinHeaderJars), extraCombinedJars...) headerJarFileWithoutDepsOrJarjar, j.headerJarFile, j.repackagedHeaderJarFile = j.compileJavaHeader(ctx, uniqueJavaFiles, srcJars, deps, flags, jarName, extraJars) if ctx.Failed() { @@ -1385,6 +1385,8 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath } } + jars = append(jars, extraCombinedJars...) + j.srcJarArgs, j.srcJarDeps = resourcePathsToJarArgs(srcFiles), srcFiles var includeSrcJar android.WritablePath @@ -1471,8 +1473,6 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath jars = append(jars, servicesJar) } - jars = append(android.CopyOf(extraCombinedJars), jars...) - // Combine the classes built from sources, any manifests, and any static libraries into // classes.jar. If there is only one input jar this step will be skipped. var outputFile android.OutputPath