diff options
author | 2025-01-18 03:16:23 +0000 | |
---|---|---|
committer | 2025-01-22 10:43:39 -0800 | |
commit | 3e11274ec70b7a2cfe74fa9d620b4ca140f2631e (patch) | |
tree | ea5c30d1643a345b6afa01d7e835fbee96157b36 /java/base.go | |
parent | da481ebb2866117f03278654e0aed4dd8362f6bc (diff) |
Change android over to Kotlin 2 by default
Fixes: 383569207
Flag: KOTLIN_LANG_VERSION
Test: m && presubmits
Change-Id: Ifeff06a71048e362a86d3563e513b8138093d8af
Diffstat (limited to 'java/base.go')
-rw-r--r-- | java/base.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/java/base.go b/java/base.go index b55c93852..6f9498ebe 100644 --- a/java/base.go +++ b/java/base.go @@ -1342,12 +1342,17 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath // For now, avoid targeting language versions directly, as we'd like to kee our source // code version aligned as much as possible. Ideally, after defaulting to "2", we // can remove the "1.9" option entirely, or at least make it emit a warning. - kotlin_lang_version := proptools.StringDefault(j.properties.Kotlin_lang_version, "1.9") - if kotlin_lang_version == "1.9" { + kotlin_default_lang_version := "1.9" + if build_flag_lang_version, ok := ctx.Config().GetBuildFlag("RELEASE_KOTLIN_LANG_VERSION"); ok { + kotlin_default_lang_version = build_flag_lang_version + } + kotlin_lang_version := proptools.StringDefault(j.properties.Kotlin_lang_version, kotlin_default_lang_version) + switch kotlin_lang_version { + case "1.9": kotlincFlags = append(kotlincFlags, "-language-version 1.9") - } else if kotlin_lang_version == "2" { + case "2": kotlincFlags = append(kotlincFlags, "-Xsuppress-version-warnings", "-Xconsistent-data-class-copy-visibility") - } else { + default: ctx.PropertyErrorf("kotlin_lang_version", "Must be one of `1.9` or `2`") } |