Put kotlin classes in header jar
If a module has kotlin sources the compiled kotlin clsases must be put in the header jar for anything that depends on the module to use. Bug: 113153312 Test: m checkbuild Change-Id: Ibc44e9a97655937315b03b05e51e09c2954d7008
This commit is contained in:
16
java/java.go
16
java/java.go
@@ -1013,8 +1013,6 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
|
|||||||
srcJars = append(srcJars, deps.srcJars...)
|
srcJars = append(srcJars, deps.srcJars...)
|
||||||
srcJars = append(srcJars, extraSrcJars...)
|
srcJars = append(srcJars, extraSrcJars...)
|
||||||
|
|
||||||
var jars android.Paths
|
|
||||||
|
|
||||||
jarName := ctx.ModuleName() + ".jar"
|
jarName := ctx.ModuleName() + ".jar"
|
||||||
|
|
||||||
javaSrcFiles := srcFiles.FilterByExt(".java")
|
javaSrcFiles := srcFiles.FilterByExt(".java")
|
||||||
@@ -1029,6 +1027,8 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
|
|||||||
|
|
||||||
var stripFiles []string
|
var stripFiles []string
|
||||||
|
|
||||||
|
var kotlinJars android.Paths
|
||||||
|
|
||||||
if srcFiles.HasExt(".kt") {
|
if srcFiles.HasExt(".kt") {
|
||||||
// If there are kotlin files, compile them first but pass all the kotlin and java files
|
// If there are kotlin files, compile them first but pass all the kotlin and java files
|
||||||
// kotlinc will use the java files to resolve types referenced by the kotlin files, but
|
// kotlinc will use the java files to resolve types referenced by the kotlin files, but
|
||||||
@@ -1059,7 +1059,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
|
|||||||
flags.classpath = append(flags.classpath, kotlinJar)
|
flags.classpath = append(flags.classpath, kotlinJar)
|
||||||
|
|
||||||
// Jar kotlin classes into the final jar after javac
|
// Jar kotlin classes into the final jar after javac
|
||||||
jars = append(jars, kotlinJar)
|
kotlinJars = append(kotlinJars, kotlinJar)
|
||||||
|
|
||||||
if Bool(j.properties.Renamed_kotlin_stdlib) {
|
if Bool(j.properties.Renamed_kotlin_stdlib) {
|
||||||
// Remove any kotlin-reflect related files
|
// Remove any kotlin-reflect related files
|
||||||
@@ -1070,10 +1070,12 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
|
|||||||
} else {
|
} else {
|
||||||
// Only add kotlin-stdlib if not using (on-device) renamed stdlib
|
// Only add kotlin-stdlib if not using (on-device) renamed stdlib
|
||||||
// (it's expected to be on device bootclasspath)
|
// (it's expected to be on device bootclasspath)
|
||||||
jars = append(jars, deps.kotlinStdlib...)
|
kotlinJars = append(kotlinJars, deps.kotlinStdlib...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jars := append(android.Paths(nil), kotlinJars...)
|
||||||
|
|
||||||
// Store the list of .java files that was passed to javac
|
// Store the list of .java files that was passed to javac
|
||||||
j.compiledJavaSrcs = uniqueSrcFiles
|
j.compiledJavaSrcs = uniqueSrcFiles
|
||||||
j.compiledSrcJars = srcJars
|
j.compiledSrcJars = srcJars
|
||||||
@@ -1089,7 +1091,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
|
|||||||
j.properties.Javac_shard_size)
|
j.properties.Javac_shard_size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
j.headerJarFile = j.compileJavaHeader(ctx, uniqueSrcFiles, srcJars, deps, flags, jarName)
|
j.headerJarFile = j.compileJavaHeader(ctx, uniqueSrcFiles, srcJars, deps, flags, jarName, kotlinJars)
|
||||||
if ctx.Failed() {
|
if ctx.Failed() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1296,7 +1298,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) compileJavaHeader(ctx android.ModuleContext, srcFiles, srcJars android.Paths,
|
func (j *Module) compileJavaHeader(ctx android.ModuleContext, srcFiles, srcJars android.Paths,
|
||||||
deps deps, flags javaBuilderFlags, jarName string) android.Path {
|
deps deps, flags javaBuilderFlags, jarName string, extraJars android.Paths) android.Path {
|
||||||
|
|
||||||
var jars android.Paths
|
var jars android.Paths
|
||||||
if len(srcFiles) > 0 || len(srcJars) > 0 {
|
if len(srcFiles) > 0 || len(srcJars) > 0 {
|
||||||
@@ -1309,6 +1311,8 @@ func (j *Module) compileJavaHeader(ctx android.ModuleContext, srcFiles, srcJars
|
|||||||
jars = append(jars, turbineJar)
|
jars = append(jars, turbineJar)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jars = append(jars, extraJars...)
|
||||||
|
|
||||||
// Combine any static header libraries into classes-header.jar. If there is only
|
// Combine any static header libraries into classes-header.jar. If there is only
|
||||||
// one input jar this step will be skipped.
|
// one input jar this step will be skipped.
|
||||||
var headerJar android.Path
|
var headerJar android.Path
|
||||||
|
Reference in New Issue
Block a user