Move kotlin stdlib after javac jars

A future CL is going to treat local jars separately from dependency
jars.  Rearrange the order of the kotlin standard library jars to
come after the local jars produced by javac, which will better match
the future ordering and ease ninja file comparisions.

Bug: 308016794
Test: all soong tests pass
Flag: EXEMPT refactor
Change-Id: I9ed6a649350451bf1788077752db5222f50c0247
This commit is contained in:
Colin Cross
2024-07-29 11:30:29 -07:00
parent edec77c453
commit d1d8f17e9e

View File

@@ -1211,6 +1211,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
var kotlinJars android.Paths var kotlinJars android.Paths
var kotlinHeaderJars android.Paths var kotlinHeaderJars android.Paths
var kotlinExtraJars android.Paths
// Prepend extraClasspathJars to classpath so that the resource processor R.jar comes before // Prepend extraClasspathJars to classpath so that the resource processor R.jar comes before
// any dependencies so that it can override any non-final R classes from dependencies with the // any dependencies so that it can override any non-final R classes from dependencies with the
@@ -1321,17 +1322,8 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
kotlinJars = append(kotlinJars, kotlinJarPath) kotlinJars = append(kotlinJars, kotlinJarPath)
kotlinHeaderJars = append(kotlinHeaderJars, kotlinHeaderJar) kotlinHeaderJars = append(kotlinHeaderJars, kotlinHeaderJar)
kotlinExtraJars = append(kotlinExtraJars, deps.kotlinStdlib...)
// Jar kotlin classes into the final jar after javac kotlinExtraJars = append(kotlinExtraJars, deps.kotlinAnnotations...)
if BoolDefault(j.properties.Static_kotlin_stdlib, true) {
kotlinJars = append(kotlinJars, deps.kotlinStdlib...)
kotlinJars = append(kotlinJars, deps.kotlinAnnotations...)
kotlinHeaderJars = append(kotlinHeaderJars, deps.kotlinStdlib...)
kotlinHeaderJars = append(kotlinHeaderJars, deps.kotlinAnnotations...)
} else {
flags.dexClasspath = append(flags.dexClasspath, deps.kotlinStdlib...)
flags.dexClasspath = append(flags.dexClasspath, deps.kotlinAnnotations...)
}
} }
jars := slices.Clone(kotlinJars) jars := slices.Clone(kotlinJars)
@@ -1349,7 +1341,11 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
// allow for the use of annotation processors that do function correctly // allow for the use of annotation processors that do function correctly
// with sharding enabled. See: b/77284273. // with sharding enabled. See: b/77284273.
} }
extraJars := append(slices.Clone(kotlinHeaderJars), extraCombinedJars...) extraJars := slices.Clone(kotlinHeaderJars)
if BoolDefault(j.properties.Static_kotlin_stdlib, true) {
extraJars = append(extraJars, kotlinExtraJars...)
}
extraJars = append(extraJars, extraCombinedJars...)
var combinedHeaderJarFile android.Path var combinedHeaderJarFile android.Path
headerJarFileWithoutDepsOrJarjar, combinedHeaderJarFile = headerJarFileWithoutDepsOrJarjar, combinedHeaderJarFile =
j.compileJavaHeader(ctx, uniqueJavaFiles, srcJars, deps, flags, jarName, extraJars) j.compileJavaHeader(ctx, uniqueJavaFiles, srcJars, deps, flags, jarName, extraJars)
@@ -1427,6 +1423,13 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
} }
} }
// Jar kotlin classes into the final jar after javac
if BoolDefault(j.properties.Static_kotlin_stdlib, true) {
jars = append(jars, kotlinExtraJars...)
} else {
flags.dexClasspath = append(flags.dexClasspath, kotlinExtraJars...)
}
jars = append(jars, extraCombinedJars...) jars = append(jars, extraCombinedJars...)
j.srcJarArgs, j.srcJarDeps = resourcePathsToJarArgs(srcFiles), srcFiles j.srcJarArgs, j.srcJarDeps = resourcePathsToJarArgs(srcFiles), srcFiles