Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aaf58061 authored by Colin Cross's avatar Colin Cross
Browse files

Allow kotlin modules to skip packaging the kotlin stdlib

Host tools like lint may package their own version of the kotlin
stdlib, and any jars loaded by them shouldn't contain the platform
version.  Add a static_kotlin_stdlib property that defaults to true
to allow building the module without staticalling including the kotlin
stdlib.

Bug: 153485543
Test: m ApiFinder
Change-Id: I7da78ef493806ce4ab0050e4ee9e8d330b0509c8
Merged-In: I7da78ef493806ce4ab0050e4ee9e8d330b0509c8
(cherry picked from commit 0b67a8bd)
parent 3791b45f
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -253,6 +253,9 @@ type CompilerProperties struct {

	// List of files to include in the META-INF/services folder of the resulting jar.
	Services []string `android:"path,arch_variant"`

	// If true, package the kotlin stdlib into the jar.  Defaults to true.
	Static_kotlin_stdlib *bool `android:"arch_variant"`
}

type CompilerDeviceProperties struct {
@@ -1345,10 +1348,12 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
		// Make javac rule depend on the kotlinc rule
		flags.classpath = append(flags.classpath, kotlinJar)

		// Jar kotlin classes into the final jar after javac
		kotlinJars = append(kotlinJars, kotlinJar)
		// Jar kotlin classes into the final jar after javac
		if BoolDefault(j.properties.Static_kotlin_stdlib, true) {
			kotlinJars = append(kotlinJars, deps.kotlinStdlib...)
		}
	}

	jars := append(android.Paths(nil), kotlinJars...)