Add support for renamed kotlin stdlib.

Added new CompilerProperty flag, rename_kotlin_stdlib, which
allow to build kotlin libraries/binaries that use platform internal
version of kotlin stdlib (com.android.kotlin.*). This way, app-provided
kotlin standard library won't collide with version used internaly.

+ remove kotlinc-build.xml after compilation so it won't end up in the
result jar file

+ remove *.kotlin_module and *.kotlin_bultin filesfrom result jar file.
These files are needed only by kotlin-reflect library and
need more work to support kotlin-stdlib renaming.

Bug: 73281388
Test: java_test.go
Change-Id: Iae7ccb919e2ae9853b3f30f3dd447ebd01a1bed0
This commit is contained in:
Przemyslaw Szczepaniak
2018-03-08 13:21:55 +00:00
parent bfe65a32bb
commit 66c0c4067f
3 changed files with 43 additions and 1 deletions

View File

@@ -66,6 +66,7 @@ var (
`${config.GenKotlinBuildFileCmd} $classpath $outDir $out.rsp $srcJarDir/list > $outDir/kotlinc-build.xml &&` +
`${config.KotlincCmd} $kotlincFlags ` +
`-jvm-target $kotlinJvmTarget -Xbuild-file=$outDir/kotlinc-build.xml && ` +
`rm $outDir/kotlinc-build.xml && ` +
`${config.SoongZipCmd} -jar -o $out -C $outDir -D $outDir`,
CommandDeps: []string{
"${config.KotlincCmd}",
@@ -358,6 +359,11 @@ func TransformJarsToJar(ctx android.ModuleContext, outputFile android.WritablePa
// for downstream tools like desugar.
jarArgs = append(jarArgs, "-stripFile module-info.class")
// Remove any kotlin-reflect related files
// TODO(pszczepaniak): Support kotlin-reflect
jarArgs = append(jarArgs, "-stripFile \"*.kotlin_module\"")
jarArgs = append(jarArgs, "-stripFile \"*.kotlin_builtin\"")
if stripDirs {
jarArgs = append(jarArgs, "-D")
}