mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Bump Kotlin to 2.2.0 (#56838)
Summary: Bump to Kotlin 2.2.0 to align with internal builds ## Changelog: [Android] [Changed] - Bump Kotlin to 2.2.0 Pull Request resolved: https://github.com/facebook/react-native/pull/56838 Test Plan: CI Differential Revision: D105298435 Pulled By: cortinico fbshipit-source-id: eae5f9f19a66d15f4451ea369ad032e8acef0aff
This commit is contained in:
1 parent
d50c1b5207
commit
cb04956cde
12 files changed
+14
-137
No files matched your search
@@ -4,7 +4,7 @@ gson = "2.8.9"
|
||||
guava = "31.0.1-jre"
|
||||
javapoet = "1.13.0"
|
||||
junit = "4.13.2"
|
||||
kotlin = "2.1.20"
|
||||
kotlin = "2.2.0"
|
||||
assertj = "3.25.1"
|
||||
ktfmt = "0.22.0"
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ kotlin { jvmToolchain(17) }
|
||||
|
||||
tasks.withType<KotlinCompile>().configureEach {
|
||||
compilerOptions {
|
||||
apiVersion.set(KotlinVersion.KOTLIN_1_8)
|
||||
apiVersion.set(KotlinVersion.KOTLIN_1_9)
|
||||
// See comment above on JDK 11 support
|
||||
jvmTarget.set(JvmTarget.JVM_11)
|
||||
allWarningsAsErrors.set(
|
||||
|
||||
+1
-2
@@ -10,7 +10,6 @@ package com.facebook.react
|
||||
import com.android.build.api.variant.Variant
|
||||
import com.facebook.react.tasks.BundleHermesCTask
|
||||
import com.facebook.react.utils.BackwardCompatUtils.showJSCRemovalMessage
|
||||
import com.facebook.react.utils.KotlinStdlibCompatUtils.capitalizeCompat
|
||||
import com.facebook.react.utils.NdkConfiguratorUtils.configureJsEnginePackagingOptions
|
||||
import com.facebook.react.utils.NdkConfiguratorUtils.configureNewArchPackagingOptions
|
||||
import com.facebook.react.utils.ProjectUtils.isHermesEnabled
|
||||
@@ -22,7 +21,7 @@ import org.gradle.api.Project
|
||||
|
||||
@Suppress("SpreadOperator", "UnstableApiUsage")
|
||||
internal fun Project.configureReactTasks(variant: Variant, config: ReactExtension) {
|
||||
val targetName = variant.name.capitalizeCompat()
|
||||
val targetName = variant.name.replaceFirstChar { it.titlecase() }
|
||||
val targetPath = variant.name
|
||||
|
||||
val buildDir = layout.buildDirectory.get().asFile
|
||||
|
||||
+1
-2
@@ -11,7 +11,6 @@ package com.facebook.react.utils
|
||||
|
||||
import com.facebook.react.ReactExtension
|
||||
import com.facebook.react.model.ModelPackageJson
|
||||
import com.facebook.react.utils.KotlinStdlibCompatUtils.capitalizeCompat
|
||||
import com.facebook.react.utils.Os.cliPath
|
||||
import java.io.File
|
||||
import org.gradle.api.Project
|
||||
@@ -200,7 +199,7 @@ internal fun getHermesOSBin(): String {
|
||||
internal fun projectPathToLibraryName(projectPath: String): String =
|
||||
projectPath
|
||||
.split(':', '-', '_', '.')
|
||||
.joinToString("") { token -> token.capitalizeCompat() }
|
||||
.joinToString("") { token -> token.replaceFirstChar { it.titlecase() } }
|
||||
.plus("Spec")
|
||||
|
||||
/**
|
||||
|
||||
+2
-8
@@ -9,8 +9,6 @@ package com.facebook.react.utils
|
||||
|
||||
import com.facebook.react.ReactExtension
|
||||
import com.facebook.react.model.ModelPackageJson
|
||||
import com.facebook.react.utils.KotlinStdlibCompatUtils.lowercaseCompat
|
||||
import com.facebook.react.utils.KotlinStdlibCompatUtils.toBooleanStrictOrNullCompat
|
||||
import com.facebook.react.utils.PropertyUtils.EDGE_TO_EDGE_ENABLED
|
||||
import com.facebook.react.utils.PropertyUtils.HERMES_ENABLED
|
||||
import com.facebook.react.utils.PropertyUtils.REACT_NATIVE_ARCHITECTURES
|
||||
@@ -38,17 +36,13 @@ internal object ProjectUtils {
|
||||
} else {
|
||||
SCOPED_HERMES_ENABLED
|
||||
}
|
||||
project
|
||||
.property(propertyString)
|
||||
.toString()
|
||||
.lowercaseCompat()
|
||||
.toBooleanStrictOrNullCompat() ?: true
|
||||
project.property(propertyString).toString().lowercase().toBooleanStrictOrNull() ?: true
|
||||
} else if (project.extensions.extraProperties.has("react")) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val reactMap = project.extensions.extraProperties.get("react") as? Map<String, Any?>
|
||||
when (val enableHermesKey = reactMap?.get("enableHermes")) {
|
||||
is Boolean -> enableHermesKey
|
||||
is String -> enableHermesKey.lowercaseCompat().toBooleanStrictOrNullCompat() ?: true
|
||||
is String -> enableHermesKey.lowercase().toBooleanStrictOrNull() ?: true
|
||||
else -> HERMES_FALLBACK
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -54,7 +54,7 @@ kotlin { jvmToolchain(17) }
|
||||
|
||||
tasks.withType<KotlinCompile>().configureEach {
|
||||
compilerOptions {
|
||||
apiVersion.set(KotlinVersion.KOTLIN_1_8)
|
||||
apiVersion.set(KotlinVersion.KOTLIN_1_9)
|
||||
// See comment above on JDK 11 support
|
||||
jvmTarget.set(JvmTarget.JVM_11)
|
||||
allWarningsAsErrors.set(
|
||||
|
||||
@@ -27,7 +27,7 @@ kotlin { jvmToolchain(17) }
|
||||
|
||||
tasks.withType<KotlinCompile>().configureEach {
|
||||
compilerOptions {
|
||||
apiVersion.set(KotlinVersion.KOTLIN_1_8)
|
||||
apiVersion.set(KotlinVersion.KOTLIN_1_9)
|
||||
// See comment above on JDK 11 support
|
||||
jvmTarget.set(JvmTarget.JVM_11)
|
||||
allWarningsAsErrors.set(
|
||||
|
||||
@@ -33,7 +33,7 @@ kotlin { jvmToolchain(17) }
|
||||
|
||||
tasks.withType<KotlinCompile>().configureEach {
|
||||
compilerOptions {
|
||||
apiVersion.set(KotlinVersion.KOTLIN_1_8)
|
||||
apiVersion.set(KotlinVersion.KOTLIN_1_9)
|
||||
// See comment above on JDK 11 support
|
||||
jvmTarget.set(JvmTarget.JVM_11)
|
||||
allWarningsAsErrors.set(
|
||||
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.utils
|
||||
|
||||
import java.util.Locale
|
||||
|
||||
object KotlinStdlibCompatUtils {
|
||||
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
||||
fun String.lowercaseCompat(): String = (this as java.lang.String).toLowerCase(Locale.ROOT)
|
||||
|
||||
fun String.capitalizeCompat(): String =
|
||||
if (isNotEmpty()) {
|
||||
val firstChar = this[0]
|
||||
val uppercaseChar = Character.toUpperCase(firstChar)
|
||||
val restString = this@capitalizeCompat.substring(1)
|
||||
uppercaseChar + restString
|
||||
} else {
|
||||
this
|
||||
}
|
||||
|
||||
fun String.toBooleanStrictOrNullCompat(): Boolean? =
|
||||
when (this) {
|
||||
"true" -> true
|
||||
"false" -> false
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
@@ -7,19 +7,18 @@
|
||||
|
||||
package com.facebook.react.utils
|
||||
|
||||
import com.facebook.react.utils.KotlinStdlibCompatUtils.lowercaseCompat
|
||||
import java.io.File
|
||||
|
||||
object Os {
|
||||
|
||||
fun isWindows(): Boolean =
|
||||
System.getProperty("os.name")?.lowercaseCompat()?.contains("windows") ?: false
|
||||
System.getProperty("os.name")?.lowercase()?.contains("windows") ?: false
|
||||
|
||||
fun isMac(): Boolean = System.getProperty("os.name")?.lowercaseCompat()?.contains("mac") ?: false
|
||||
fun isMac(): Boolean = System.getProperty("os.name")?.lowercase()?.contains("mac") ?: false
|
||||
|
||||
fun isLinuxAmd64(): Boolean {
|
||||
val osNameMatch = System.getProperty("os.name")?.lowercaseCompat()?.contains("linux") ?: false
|
||||
val archMatch = System.getProperty("os.arch")?.lowercaseCompat()?.contains("amd64") ?: false
|
||||
val osNameMatch = System.getProperty("os.name")?.lowercase()?.contains("linux") ?: false
|
||||
val archMatch = System.getProperty("os.arch")?.lowercase()?.contains("amd64") ?: false
|
||||
return osNameMatch && archMatch
|
||||
}
|
||||
|
||||
|
||||
-82
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.utils
|
||||
|
||||
import com.facebook.react.utils.KotlinStdlibCompatUtils.capitalizeCompat
|
||||
import com.facebook.react.utils.KotlinStdlibCompatUtils.lowercaseCompat
|
||||
import com.facebook.react.utils.KotlinStdlibCompatUtils.toBooleanStrictOrNullCompat
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Test
|
||||
|
||||
class KotlinStdlibCompatUtilsTest {
|
||||
|
||||
@Test
|
||||
fun lowercaseCompat_withEmptyString() {
|
||||
assertThat("".lowercaseCompat()).isEqualTo("")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun lowercaseCompat_withLowercaseString() {
|
||||
assertThat("frodo".lowercaseCompat()).isEqualTo("frodo")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun lowercaseCompat_withTitlecaseString() {
|
||||
assertThat("Frodo".lowercaseCompat()).isEqualTo("frodo")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun lowercaseCompat_withUppercaseString() {
|
||||
assertThat("FRODO".lowercaseCompat()).isEqualTo("frodo")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun capitalizeCompat_withEmptyString() {
|
||||
assertThat("".capitalizeCompat()).isEqualTo("")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun capitalizeCompat_withLowercaseString() {
|
||||
assertThat("bilbo".capitalizeCompat()).isEqualTo("Bilbo")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun capitalizeCompat_withTitlecaseString() {
|
||||
assertThat("Bilbo".capitalizeCompat()).isEqualTo("Bilbo")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun capitalizeCompat_withUppercaseString() {
|
||||
assertThat("BILBO".capitalizeCompat()).isEqualTo("BILBO")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toBooleanStrictOrNullCompat_withEmptyString() {
|
||||
assertThat("".toBooleanStrictOrNullCompat()).isNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toBooleanStrictOrNullCompat_withfalse() {
|
||||
assertThat("false".toBooleanStrictOrNullCompat()).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toBooleanStrictOrNullCompat_withCapitalTrue_returnsNull() {
|
||||
assertThat("True".toBooleanStrictOrNullCompat()).isNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toBooleanStrictOrNullCompat_withCapitalFalse_returnsNull() {
|
||||
assertThat("False".toBooleanStrictOrNullCompat()).isNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toBooleanStrictOrNullCompat_withRandomInput_returnsNull() {
|
||||
assertThat("maybe".toBooleanStrictOrNullCompat()).isNull()
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ javax-inject = "1"
|
||||
jsc-android = "2026004.0.1"
|
||||
jsr305 = "3.0.2"
|
||||
junit = "4.13.2"
|
||||
kotlin = "2.1.20"
|
||||
kotlin = "2.2.0"
|
||||
ktfmt = "0.22.0"
|
||||
mockito = "3.12.4"
|
||||
mockito-kotlin = "3.2.0"
|
||||
|
||||
Reference in new issue
Block a user